Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

The method of data data Operation and function call in WeChat Mini Programs Page

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)05/31 Report--

The knowledge of this article "WeChat Mini Programs Page data data manipulation and function call method" is not understood by most people, so the editor summarizes the following contents, detailed contents, clear steps, and has a certain reference value. I hope you can get something after reading this article. Let's take a look at this "WeChat Mini Programs Page data data operation and function call method" article.

WeChat Mini Programs explains data data operation and function call in Page in detail.

The Page () function is used to register a page. Accept an object parameter that specifies the initial data of the page, lifecycle functions, event handlers, and so on.

/ index.js Page ({data: {text: "This is page data.", sliderOffset: 0, sliderLeft: 0, state: {genre: [], genre_index: 0, model: [], model_index: 0, terminalStatus:'',}}, onLoad: function (options) {/ / Do some initialize when page load. }, onReady: function () {/ / Do something when page ready. }, onShow: function () {/ / Do something when page show. }, onHide: function () {/ / Do something when page hide. }, onUnload: function () {/ / Do something when page close. }, onPullDownRefresh: function () {/ / Do something when pull down. }, onReachBottom: function () {/ / Do something when page reach bottom. }, / / Event handler. ViewTap: viewTap: function () {var p = this.position ball (p150) function ball (XMagi y) {console.log (XMagi y)}}, customData: {hi: 'MINA'}})

1. Set data data

The setData function is used to send data from the logical layer to the view layer while changing the value of the corresponding this.data.

Note:

(1), directly modify the this.data is invalid, can not change the status of the page, but also cause data inconsistency.

(2) the data set at a time cannot exceed 1024kB, so try to avoid setting too much data at one time.

SetData () parameter format: accepts an object in the form of key,value to change the corresponding value of key in this.data to value. Key can be very flexible, given in the form of data paths, such as array [2] .message, a.b.c.d, and does not need to be pre-defined in this.data.

The following sets the values of text and genre_index in data

This.setData ({'state.genre_index':1, text:'data value'})

2. Obtain data data

This is required to get the text and genre_ index values in data

Var gener_index=this.data.state.genre_indexvar text=this.data.text

3. Call the viewTap function

Calling the internal ball function in the viewTap function can be called directly. If you need to call the viewTap function in the onReady function, you need to use this.

OnReady: function () {this.drawBall ()}

The above is about the content of this article on "methods of data data manipulation and function calls in WeChat Mini Programs Page". I believe we all have some understanding. I hope the content shared by the editor will be helpful to you. If you want to know more related knowledge, please pay attention to the industry information channel.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report