微信小程序中调用page中自定义的函数

微信小程序中调用page中自定义的函数

如下所示,在函数中如果不加this的话控制台会报错:

this.initalEncryptedInput();
 onLoad:function(){
    this.initalEncryptedInput();
 }
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:'',
   encryptedInputFocus:false,
    originalTextFocus:false,
   decryptedInputFocus:false,
  },
   initalEncryptedInput:function(){
     let pass = wx.getStorageSync('encode');
    if(pass == '' || pass == undefined) {
     this.setData({
        encryptedInputFocus: true,
       });
   } else {
       this.setData({
      encryptedPassword: pass,
     originalTextFocus: true,
     });
   }
  },
 onLoad:function(){
    this.initalEncryptedInput();
 },
})



你可能感兴趣的:(微信小程序)