js中如何在data中访问properties中的数据?

小程序 文章 2022-03-04 12:20 319 0 全屏看文

AI助手支持GPT4.0

js中如何在data中访问properties中的数据?How to access data in properties in data in js?

js中如何在data中访问properties中的数据?

如图,刚刚小程序入门,没学多久,js也没啥基础,问问大佬们这个该如何是好

As shown in the figure, I just started the small program. I haven't learned it for a long time, and JS has no foundation. Ask the big guys what to do about it

回答:

brave:
// 基础库版本 2.6.1 开始支持Component({  properties: {..............},  data: {    tabs: []  },  observers: {    'tab1, tab2, tab3, tab4': function(tab1, tab2, tab3, tab4) {      this.setData({        tabs: [{          value: tab1        },{          value: tab2        },{          value: tab3        },{          value: tab4        }]      })    }  }})


深圳市春夏秋冬信息互联科技有限公司:
Component({  properties: {..............},  data: {    tabs: []  },  observers: {    'tab1, tab2, tab3, tab4': function(tab1, tab2, tab3, tab4) {      this.setData({        tabs: [{          value: tab1        },{          value: tab2        },{          value: tab3        },{          value: tab4        }]      })    }  }})// 基础库版本 2.6.1 开始支持
p3:成了成了! 但是为啥在observer里面可以调取呢,properties里面的value应该是随页面加载应该就会有的吧
深圳市春夏秋冬信息互联科技有限公司:这个是数据监听器,一旦值有变化,他就触发 https://developers.weixin.qq.com/miniprogram/dev/framework/custom-component/observer.html
胡家内:壬片

-EOF-

AI助手支持GPT4.0