Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

我想封装一个公用的富文本子组件,父子组件传参使用props, $emit传参,子组件使用props接收参数content,在created 设置初始值,在watch监听父组件的改变的值content改变子组件的值valueData(比如请求接口后父组件传值渲染子组件),通过$emit 监听子组件富文本改变的同时修改父组件的值;
但是这样会导致子组件富文本每输入一个字都会触发 $emit 传到父组件,改变父组件的值,然后子组件又触发watch 修改一遍子组件的valueData,绕了一圈;
请教下有没有更优雅的方案(除了vuex)?

子组件VueEditor.vue
image.png

父组件
image.png


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
1.7k views
Welcome To Ask or Share your Answers For Others

1 Answer

参考自定义v-model的用法


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...