微信小程序Page中data数据操作和函数调用
发布日期:2021-05-08 17:17:29 浏览次数:16 分类:精选文章

本文共 1160 字,大约阅读时间需要 3 分钟。

微信小程序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', });

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

var text=this.data.text   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:'',  }, 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;",    })  },)}

上一篇:微信小程序中调用page中自定义的函数
下一篇:不能读取变量的length属性

发表评论

最新留言

初次前来,多多关照!
[***.217.46.12]2025年04月18日 16时48分25秒