比方需要拿到这个H2标签的文本内容
<h2>Ecosystem</h2>
那么先给这个元素加个触发事件
<h2 v-on:click="greet">Ecosystem</h2>
然后在methods中添加事件函数
methods: {
greet: function (event) {
console.log(event.target.innerText);//打印得到了Ecosystem
}
}
比方需要拿到这个H2标签的文本内容
<h2>Ecosystem</h2>
那么先给这个元素加个触发事件
<h2 v-on:click="greet">Ecosystem</h2>
然后在methods中添加事件函数
methods: {
greet: function (event) {
console.log(event.target.innerText);//打印得到了Ecosystem
}
}