watch: { currentSwiper: { handler(newInfo, oldInfo) { // console.log("监听") if(newInfo == 0 || newInfo == 1){ this.navTitle = this.tabberList[newInfo].title }else{ this.navTitle = "卷卷x" + this.tabberList[newInfo].title } this.currentData = this.tabberList[newInfo] this.formData = { userid: uni.getStorageSync('userid_storage'), mobile: '', province: '', city:'' } this.huaIndex = 0 this.mianList = [] this.huiyuanList = [] this.huiyuanTypeActive = 0 this.huiyuanTypeName = '' this.huiyuanRule = '' if (this.currentData.type == 1) { this.getHuafei() }else{ this.getDetail() } }, },
时间: 2024-04-27 12:25:20 浏览: 92
微信小程序:小技巧系列合辑No.1
这段代码是Vue组件中的watch监听器,当currentSwiper属性值发生变化时会自动执行handler函数。在这个函数中,首先根据currentSwiper的值设置navTitle属性,然后根据currentSwiper的值设置其他属性的初始值,包括currentData、formData、huaIndex、mianList、huiyuanList、huiyuanTypeActive、huiyuanTypeName和huiyuanRule。最后根据currentData的type属性值决定调用getHuafei()方法还是getDetail()方法。
阅读全文