Vue v-html標簽使用過濾器
前端需要展示HTML格式內(nèi)容,還要使用過濾器,限制內(nèi)容展示長度
1.創(chuàng)建過濾器。
filters: {
ellipsis (value, num) {
// code there...
}
}
2.使用過濾器
<h2 v-html="$options.filters.ellipsis(content, 30)">
前端需要展示HTML格式內(nèi)容,還要使用過濾器,限制內(nèi)容展示長度
1.創(chuàng)建過濾器。
filters: {
ellipsis (value, num) {
// code there...
}
}
2.使用過濾器
<h2 v-html="$options.filters.ellipsis(content, 30)">