问题
Using object.on('selected', function() {}), I can get the image object that is clicked. My intent is to redirect to an URL by clicking it. How can I add an URL to an image, or more general, to an object in Fabric.js?
回答1:
You can simply navigate to the target page in the selected
event handler:
object.on('selected', function() {
window.location.href = "http://www.example.com/";
})
来源:https://stackoverflow.com/questions/29585568/how-to-add-url-to-an-image-in-fabric-js