希望做与此类似的事情:Get the calling element with vue.js
但是我想通过类的绑定来实现。这可能吗?
尝试获取元素或事件: https://jsfiddle.net/mrxunvyw/
new Vue({
el: "#app",
methods: {
testFunction: function(event) {
console.log(event);
return true;
}
}
});
.title{
font-size: 24pt;
}
<script src="https://vuejs.org/js/vue.js"></script>
<div id="app">
<div :class="{title: testFunction()}">Test1</div>
<div :class="{title: testFunction()}">Test2</div>
<div :class="{title: testFunction()}">Test3</div>
<div :class="{title: testFunction()}">Test4</div>
</div>