Fe-interview: [vue] vue2.0不再支持v-html中使用过滤器了怎么办?

Created on 2 Jul 2019  ·  4Comments  ·  Source: haizlin/fe-interview

[vue] vue2.0不再支持v-html中使用过滤器了怎么办?

vue

Most helpful comment

1:全局方法

2:computed

3:$options.filters

All 4 comments

在method中定义方法

htmlFilter(htmlString){
return htmlString.replace(/+s/g,'')
}

在vue中 v-html="htmlFilter(htmlString)"即可

1:全局方法

2:computed

3:$options.filters

使用过滤器 Vue.filter

其实这些问题是工作的时候也会遇到的很重要的问题,熟练掌握记住api这真的是件好事

Was this page helpful?
0 / 5 - 0 ratings