我正在尝试在href中的URL中设置动态值。我正在使用Vue.js
<a
href="https://example.com/glasses/guide-for-uploading"
target="_blank"
>
Check it here
</a>
因此,在URL的中间,我需要用productName替换眼镜。如何在此链接中正确完成?我不确定是否需要简单的数据绑定。
答案 0 :(得分:0)
是的,您可以使用数据绑定。
<a
:href="`https://example.com/glasses/${productName}`"
target="_blank"
>
Check it here
</a>
答案 1 :(得分:0)
您可以像这样绑定href:
:href="'https://example.com/glasses/${productName}'"
或者您可以使用字符串获得相同的结果:
Let link = document.getElemntById("linkId")
Let address = "https://example.com/glasses/" + this.productName
link.href = address