Vue -学习

Vue 点击内容

2019-04-28  本文已影响0人  白云青叶

Vue 如何获取当前点击的内容

例子:

<span @click="clickTest" id="test">Test</span>

clickTest: function(e){

    console.log(e.target);

    console.log(e.target.innerText);

    console.log(e.target.getAttribute("id"));

}

可直接通过console.log 获得e.target 的内容,查看对应的属性

其中innerText 为 获得span 内的内容

getAttribute 为获取span 属性的值

上一篇 下一篇

猜你喜欢

热点阅读