t***@126.com
t***@126.com
  • 发布:2019-11-19 16:48
  • 更新:2024-08-05 13:15
  • 阅读:4562

使用vuex后watch触发多次

分类:uni-app

从A页面去到B页面然后再回到A页面,这样的轮回有多少次就会导致watch中的方法执行多少次。这是为什么呢?

computed: {  
        ...mapState({  
            timeStamp: state => state.finishNormalOrder.timeStamp,  
            id: state => state.finishNormalOrder.id,  
            drop: state => state.finishNormalOrder.drop,  
            reasonName: state => state.finishNormalOrder.reasonName,  
            reasonId: state => state.finishNormalOrder.reasonId,  
            userId: state => state.finishNormalOrder.userId,  
            userName: state => state.finishNormalOrder.userName,  
            remindType: state => state.finishNormalOrder.remindType,  
            signed: state => state.finishNormalOrder.signed,  
            signImage: state => state.finishNormalOrder.signImage,  
            labelList: (state) => {  
                return state.finishNormalOrder.labelList;  
            },  
            imageList: state => state.finishNormalOrder.imageList  
        }),  
        content: {  
            get() {  
                return this.$store.state.finishNormalOrder.content;  
            },  
            set(val) {  
                this.updateOrder({ content: val });  
            }  
        }  
    },  
    watch: {  
        reasonId(value) {  
            console.log(value)  
            this.queryLabel(value);  
        }  
    },  
    methods: {  
        ...mapMutations({  
            updateOrder: 'finishNormalOrder/updateOrder'  
        }),  
       }
2019-11-19 16:48 负责人:无 分享
已邀请:
牵着蜗牛散步

牵着蜗牛散步

同样遇到这个问题 watch vuex中的state数据 会触发多次

Azikou

Azikou

23年了, 还是没人解答/

huangjianshu

huangjianshu

要回复问题请先登录注册