javascript - VueJS组件中的复制链接选项不起作用
问题描述
在我的 laravel/vue 应用程序中,我可以选择在用户单击图标时复制链接。
到目前为止,我的组件中有以下内容
<a href="sample.site" class="text-dark" target="_blank" rel="noopener noreferrer" ref="mylink">
<img class="social_icon" @click="copyURL($refs.mylink)"
src="/images/game/copy.png"
/></a>
<p>copied: {{ link }}</p>
我有以下内容
<script>
export default {
};
const app = new Vue({
el: '#app',
data() {
return {
link: ''
}
},
methods: {
copyURL(link) {
this.link = link.href
}
}
})
</script>
但这不起作用或没有显示任何错误
解决方案
您还没有调用该方法copyURL
<a :href="sample.site" @click="copyURL" ref="mylink">
<img class="social_icon" src="/images/game/copy.png" />
</a>
推荐阅读
- java - 如何将 c:forEach 与 arrayList 一起使用?
- c++ - 将一个向量分配给另一个向量
- android - lateinit 属性映射尚未初始化
- python - Django 无法读取 POSTMAN 发布的数据?
- c - 如何将传入数据包的源端口分配给传出数据包的目标端口 - TCP C Linux
- c# - 带有会话参数的数据库 ASP.NET MVC 中的编辑操作不会更新
- google-analytics - 跟踪 ID 只能采用 UA-NNNNNN-N 格式
- c - 为什么进位位永远不是1?我查看了程序内存,从来没有 1,只有 0
- python - NumPy `a.resize` 添加非零值
- c++ - 真正的“对象函数”只在头文件中?