vue中子组件修改props

父组件用sync修饰,子组件在 computed 的 set 中通过$emit('update:参数',值)函数去修改。

<!-- 父组件 -->
<customComponent :isShow.sync="isShow"></customComponent>

<!-- 子组件 -->
computed() {
    show: {
        get() {
             return this.isShow;
        },
        set(v) {
             this.$emit('update:show', v);
        }
    }
}

 

posted @ 2022-04-28 10:32  沐子馨  阅读(375)  评论(0编辑  收藏  举报