刪除Vue的自定義過濾器,我想利用VueJS 2.鼠標懸停在這裏刪除截斷過濾器是我的模板過濾器:鼠標懸停
<div class="eng" @mouseover="showAll">{{ word.english | truncate }}</div>
這裏是過濾器本身:
filters: {
truncate: function(value) {
let length = 50;
if (value.length <= length) {
return value;
} else {
return value.substring(0, length) + '...';
}
}
},
有沒有辦法在mouseover事件中刪除過濾器,以便div不會被截斷?謝謝!
編輯:showAll()
功能是我認爲我會刪除它的地方。我嘗試了幾種方法去除過濾器,例如:
showAll(){
console.log('being mousedover');
this.truncate = false
},
和:
showAll(){
console.log('being mousedover');
!this.truncate
}
但是這是我迷路了......
當你將鼠標放置做任何事情發生嗎?你可以包含'showAll'的代碼嗎? – Libby