0

我有带有文本“This is google.com”的文本框,我想将超链接设置为仅单词“google.com”而不是整个文本框文本。如何设置/获取子字符串的超链接?

var canvas = new fabric.Canvas('c');

var urlText = new fabric.Textbox("This is google.com", {
});

urlText.setSelectionStyles({ underline: true }, 8, 18)
urlText.setSelectionStyles({linkURL: "https://www.google.com/"}, 2, 4)
urlText.setSelectionStyles({linkName:"google.com"}, 8, 18)
urlText.setSelectionStyles({fill:"rgba(0,0,255,1)"}, 8, 18)
canvas.add(urlText);
canvas {
    border: 1px solid #999;
}
<script src="https://rawgit.com/kangax/fabric.js/master/dist/fabric.js"></script>
<canvas id="c" width="1000" height="500"></canvas>

你能帮我在google.com上获得可点击的事件吗?

谢谢。任何帮助将不胜感激。

4

0 回答 0