phone:{ handler(newInfo, oldInfo) { this.yunyingshang = '' if(newInfo.length == 11){ this.getYunyingshang(newInfo) } } }
时间: 2024-04-27 17:25:16 浏览: 11
这段代码是Vue组件中的watch监听器,当phone属性值发生变化时会自动执行handler函数。在这个函数中,首先将yunyingshang属性重置为空字符串。然后判断phone的长度是否为11,如果是则调用getYunyingshang(newInfo)方法,该方法会通过手机号查询运营商信息并将结果赋值给yunyingshang属性。
相关问题
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() } }, },
这段代码是Vue组件中的watch监听器,当currentSwiper属性值发生变化时会自动执行handler函数。在这个函数中,首先根据currentSwiper的值设置navTitle属性,然后根据currentSwiper的值设置其他属性的初始值,包括currentData、formData、huaIndex、mianList、huiyuanList、huiyuanTypeActive、huiyuanTypeName和huiyuanRule。最后根据currentData的type属性值决定调用getHuafei()方法还是getDetail()方法。
watch:{ obj:{ deep: true, handler(){ this.praiseLen = this.obj["praise_len"] } } }
这段代码是 Vue.js 中的一个监听器(watcher),它会监听一个对象(obj)中的 deep 属性的变化,一旦 deep 属性的值发生改变,它就会执行 handler 函数。在 handler 函数中,它将 obj 对象中的 praise_len 属性的值赋值给 Vue 实例中的 praiseLen 属性。这样,当 obj 中的 deep 属性或 praise_len 属性的值发生改变时,praiseLen 属性也会相应地更新。
相关推荐
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)