最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

微信小程序報(bào)錯(cuò):this.setData is not a function的解決辦法

 更新時(shí)間:2017年09月27日 15:41:50   作者:tangxiujiang  
這篇文章主要介紹了微信小程序報(bào)錯(cuò):this.setData is not a function的解決辦法的相關(guān)資料,希望通過本文能幫助到大家解決這樣類似的問題,需要的朋友可以參考下

微信小程序 報(bào)錯(cuò):this.setData is not a function

在page中定義的代碼如下,代碼會(huì)報(bào)錯(cuò):this.setData is not a function

<strong> pasteEncryptedText:function()</strong>{ 
 let decryptedPass = this.data.decryptedPassword; 
 if (decryptedPass == '' ){ 
 wx.showToast({ 
 title: '請先輸入解密密碼', 
 mask: true, 
 success: function (res) { 
  setTimeout(function () { 
  wx.hideToast(); 
  }, 4000); 
 }, 
 }); 
 return; 
 }else{ 
 wx.getClipboardData({ 
 <strong>success: function (res)</strong> { 
  if ( res.data == '' ){ 
  wx.showToast({ 
  title: '剪貼板沒有內(nèi)容', 
  mask: true, 
  success: function (res) { 
  setTimeout(function () { 
   wx.hideToast(); 
  }, 4000); 
  }, 
  }) 
  }else{ 
  console.log(decryptedPass); 
  console.log(res.data); 
  <strong>this.setData({ 
  encryptedTextDecode: res.data, 
  originalTextDecode: desEncryptedDecrypted.decrypt(res.data, decryptedPass), 
  });</strong> 
  console.log(this.data.originalTextDecode); 
  } 
 } 
 }); 
 } 
 } 

問題分析:在函數(shù) pasteEncryptedText()里面嵌套調(diào)用另一個(gè)函數(shù) wx.showToast(),而setData()是在wx.showToast()中調(diào)用的,此時(shí)this.setData() 

中的this不是page,而是wx.showToast()這個(gè)對象了 

解決方法:

<strong> 在函數(shù)pasteEncryptedText()一開始處將this對象保存:</strong>let that = this; 
pasteEncryptedText:function(){ 
 let decryptedPass = this.data.decryptedPassword; 
<strong>let that = this;</strong> 
if (decryptedPass == '' ){ 
 wx.showToast({ 
 title: '請先輸入解密密碼', 
 mask: true, 
 success: function (res) { 
 setTimeout(function () { 
 wx.hideToast(); 
 }, 4000); 
 }, 
 }); 
 return; 
}else{ 
 wx.getClipboardData({ 
 success: function (res) { 
 if ( res.data == '' ){ 
 wx.showToast({ 
  title: '剪貼板沒有內(nèi)容', 
  mask: true, 
  success: function (res) { 
  setTimeout(function () { 
  wx.hideToast(); 
  }, 4000); 
  }, 
 }) 
 }else{ 
 console.log(decryptedPass); 
 console.log(res.data); 
 <strong> that.setData</strong>({ 
  encryptedTextDecode: res.data, 
  originalTextDecode: desEncryptedDecrypted.decrypt(res.data, decryptedPass), 
 }); 
 console.log(<strong>that.data.originalTextDecode</strong>); 
 } 
 } 
 }); 
} 

如有疑問請留言或者到本站社區(qū)交流討論,感謝閱讀,希望通過本文能幫助到大家,謝謝大家對本站的支持!

相關(guān)文章

最新評論

景泰县| 尚义县| 三穗县| 阳新县| 平遥县| 田东县| 奇台县| 法库县| 宁武县| 克什克腾旗| 邵武市| 湘潭市| 罗定市| 彰化县| 吉木萨尔县| 隆回县| 宜丰县| 克什克腾旗| 青铜峡市| 杭州市| 临猗县| 锡林浩特市| 靖江市| 阿鲁科尔沁旗| 崇明县| 靖边县| 会宁县| 临武县| 寿宁县| 喀喇沁旗| 鄯善县| 双牌县| 故城县| 万盛区| 肇州县| SHOW| 德保县| 扶余县| 宜丰县| 武定县| 柳林县|