我想使用 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) + '...';
}
}
},
有没有办法删除鼠标悬停事件上的过滤器,以便 div 不再被截断?谢谢!
编辑:showAll()
function 是我想删除它的地方。我尝试了几种方法来删除过滤器,例如:
showAll(){
console.log('being mousedover');
this.truncate = false
},
and:
showAll(){
console.log('being mousedover');
!this.truncate
}
但这就是我迷失的地方......
Make showAll
布尔数据属性和使用template
标签来确定哪个版本word.english
通过显示v-if
and v-else
指令:
<div class="eng" @mouseover="showAll = true">
<template v-if="showAll">{{ word.english }}</template>
<template v-else>{{ word.english | truncate }}</template>
</div>
这是一个工作小提琴。 https://jsfiddle.net/nqhgpv5y/1/
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)