vue-3.x-demos icon indicating copy to clipboard operation
vue-3.x-demos copied to clipboard

关于@vue/composition-api中computed方法的疑惑

Open linglingyun10 opened this issue 5 years ago • 0 comments

您好,我把您这个项目的index.html分成了三个组件,出现了一个问题,remaing参数通过父组件传入到子组件,没有动态响应,不知道为啥,麻烦您给解答一下可以么?代码如下,子组件的watch只执行了一次 //父组件 <TodoList :visibility="visibility" :todos="onShowList" @removeCompleted="removeCompleted" :remaining="remaining" /> remaining: computed({ get: () => { let activeLength = filters.active(state.todos).length; return activeLength; }, set: function(val) { console.log(val); } }) //子组件 props: { todos: Array, visibility: String, remaining: Number }, watch( () => state.remaining, (newVal, oldVal) => { console.log("====newVal=", newVal); console.log("====oldVal=", oldVal); } );

linglingyun10 avatar Mar 19 '20 15:03 linglingyun10