vue2.0不再支持v-html中使用过滤器了怎么办?
2020-01-03 本文已影响0人
死敲代码的
- methods中定义方法
<template>
<div class="home" v-html="htmlFilter(html)"></div>
</template>
<script>
export default {
data() {
return{
html: "a、bc、defg"
}
},
methods:{
/*去除所有的顿号*/
htmlFilter(htmlString){
return htmlString.split('、').join('');
}
}
}
</script>
- computed
<template>
<div class="home" v-html="newHtml"></div>
</template>
<script>
export default {
data() {
return{
html: "a、bc、defg"
}
},
computed:{
newHtml(){
return this.html.split('、').join('');
}
}
}
</script>