Vue 2.0 不再支持在 v-html 中使用过滤器怎么办?
发布于 4 年前 作者 banyungong 2740 次浏览 来自 分享
粉丝福利 : 关注VUE中文社区公众号,回复视频领取粉丝福利

①全局方法(推荐)

Vue.prototype.msg = function(msg){ return msg.replace("\n","
") }

②computed方法

computed:{ content:function(msg){ return msg.replace("\n","
") } }

{{content}}
③$options.filters(推荐)

filters:{ msg:function(msg){ return msg.replace(/\n/g,"
") } },    data:{ content:“XXXX” }

回到顶部