v-mode 提示错误 v-model directives require the attribute value which is valid as LHS.

前端之家收集整理的这篇文章主要介绍了v-mode 提示错误 v-model directives require the attribute value which is valid as LHS.前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
@H_404_0@v-mode总是提示错误 v-model  directives require the attribute value which is valid as LHS.

@H_404_0@

image.png

@H_404_0@为什么调用过滤总是提示这个错呢?

解决方法

@H_404_0@v-model 的值只能是一个变量,是无法应用 filter 的。如果需要应用 filter:

v-model="msgFilteredHTML"

export default {
    ...
    computed: { 
        msgFilteredHTML: {
            get() {
                return this.filterHTML(this.msg)
            },
            set(val) {
                this.msg = val
            }
        }
    }
}

猜你在找的Vue相关文章