Detailed explanation of data data operations and function calls in WeChat applet Page

小云云
Release: 2018-05-19 15:46:49
Original
8161 people have browsed it

本文主要介绍微信小程序Page中data数据操作和函数调用的相关资料,希望通过本文能帮助到大家掌握这方法,需要的朋友可以参考下,希望能帮助到大家。

微信小程序Page中data数据获取和设置

一、Page中data数据的获取和设置:

       1、设置data数据 this.setData(object)

setData() 参数格式:接受一个对象,以 key,value 的形式表示将 this.data 中的 key 对应的值改变成 value。其中 key 可以非常灵活,以数据 路径的形式给出,如 array[2].message,a.b.c.d,并且不需要在 this.data 中预先定义。 

this.setData({ 
; encryptionPage: 'display:block', 
});
Copy after login

2、获取data数据 this.data.object

var text=this.data.text
Copy after login
Page({ 
 data: { 
 encryption: "color: green; border-bottom-color: green; border-bottom-size: 1px; border-bottom-style: solid;", 
 decryption: "color: gray; border-bottom-color: #F5F5F5; border-bottom-size: 1px; border-bottom-style: solid;", 
 encryptionPage:'display:block', 
 decryptionPage:'display:none', 
 originalText:'', 
 encryptedText:'', 
 originalTextDecode:'', 
 encryptedTextDecode:'', 
 encryptedPassword:'', 
 decryptedPassword:'', 
},
Copy after login
 setEncryption: function(e){ 
 this.setData({ 
 encryptionPage: 'display:block', 
 decryptionPage: 'display:none', 
 encryption: "color: green; border-bottom-color: green; border-bottom-size: 1px; border-bottom-style: solid;", 
 decryption: "color: gray; border-bottom-color: #F5F5F5; border-bottom-size: 1px; border-bottom-style: solid;", 
 }) 
 }, 
)}
Copy after login

相关推荐:

微信小程序把文字玩出花样(弹幕)

The above is the detailed content of Detailed explanation of data data operations and function calls in WeChat applet Page. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!