如何在Fabric.js中向图像添加URL? [英] How to add URL to an image in Fabric.js?

查看:373
本文介绍了如何在Fabric.js中向图像添加URL?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用object.on('selected',function(){}),我可以获取被单击的图像对象.我的目的是通过单击重定向到URL.如何在Fabric.js中将URL添加到图像或更一般的对象?

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?

推荐答案

您可以简单地在selected事件处理程序中导航到目标页面:

You can simply navigate to the target page in the selected event handler:

object.on('selected', function() {
    window.location.href = "http://www.example.com/";
})

这篇关于如何在Fabric.js中向图像添加URL?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆