国产99久久精品_欧美日本韩国一区二区_激情小说综合网_欧美一级二级视频_午夜av电影_日本久久精品视频

最新文章專題視頻專題問答1問答10問答100問答1000問答2000關(guān)鍵字專題1關(guān)鍵字專題50關(guān)鍵字專題500關(guān)鍵字專題1500TAG最新視頻文章推薦1 推薦3 推薦5 推薦7 推薦9 推薦11 推薦13 推薦15 推薦17 推薦19 推薦21 推薦23 推薦25 推薦27 推薦29 推薦31 推薦33 推薦35 推薦37視頻文章20視頻文章30視頻文章40視頻文章50視頻文章60 視頻文章70視頻文章80視頻文章90視頻文章100視頻文章120視頻文章140 視頻2關(guān)鍵字專題關(guān)鍵字專題tag2tag3文章專題文章專題2文章索引1文章索引2文章索引3文章索引4文章索引5123456789101112131415文章專題3
問答文章1 問答文章501 問答文章1001 問答文章1501 問答文章2001 問答文章2501 問答文章3001 問答文章3501 問答文章4001 問答文章4501 問答文章5001 問答文章5501 問答文章6001 問答文章6501 問答文章7001 問答文章7501 問答文章8001 問答文章8501 問答文章9001 問答文章9501
當前位置: 首頁 - 科技 - 知識百科 - 正文

微信小程序報錯:this.setData is not a function的解決辦法

來源:懂視網(wǎng) 責編:小采 時間:2020-11-27 22:28:56
文檔

微信小程序報錯:this.setData is not a function的解決辦法

微信小程序報錯:this.setData is not a function的解決辦法:微信小程序 報錯:this.setData is not a function 在page中定義的代碼如下,代碼會報錯:this.setData is not a function <strong> pasteEncryptedText:function()</strong>{ let decrypted
推薦度:
導(dǎo)讀微信小程序報錯:this.setData is not a function的解決辦法:微信小程序 報錯:this.setData is not a function 在page中定義的代碼如下,代碼會報錯:this.setData is not a function <strong> pasteEncryptedText:function()</strong>{ let decrypted

微信小程序 報錯:this.setData is not a function

在page中定義的代碼如下,代碼會報錯: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)用另一個函數(shù) wx.showToast(),而setData()是在wx.showToast()中調(diào)用的,此時this.setData() 

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

解決方法:

<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ū)交流討論,感謝閱讀,希望通過本文能幫助到大家,謝謝大家對本站的支持!

聲明:本網(wǎng)頁內(nèi)容旨在傳播知識,若有侵權(quán)等問題請及時與本網(wǎng)聯(lián)系,我們將在第一時間刪除處理。TEL:177 7030 7066 E-MAIL:11247931@qq.com

文檔

微信小程序報錯:this.setData is not a function的解決辦法

微信小程序報錯:this.setData is not a function的解決辦法:微信小程序 報錯:this.setData is not a function 在page中定義的代碼如下,代碼會報錯:this.setData is not a function <strong> pasteEncryptedText:function()</strong>{ let decrypted
推薦度:
  • 熱門焦點

最新推薦

猜你喜歡

熱門推薦

專題
Top
主站蜘蛛池模板: 一区二区三区四区电影 | 国产一区二区久久久 | 国产拍拍拍免费视频网站 | 亚洲欧美日韩精品专区卡通 | 欧美精品色精品一区二区三区 | 99国产精品高清一区二区二区 | 特黄一级毛片 | 国模冰冰炮交图后02 | 国产日韩欧美精品在线 | 精品成人一区二区三区免费视频 | 国产成人青青热久免费精品 | 国产一区二区精品久久91 | 成人a区 | 亚洲欧美日韩网站 | 国产不卡在线观看 | 国产免费一区二区三区香蕉精 | 国产不卡视频在线 | 国产激情一区二区三区在线观看 | 国产a免费视频 | 国产精品免费视频网站 | 国产高清免费不卡观看 | 国产免费全部免费观看 | 日韩第七页 | 久久久久久久岛国免费播放 | 伊人99热 | 日韩欧美网站 | 国产 日韩 欧美 在线 | 国产日韩视频一区 | 欧美日韩国产一区二区三区不卡 | 日韩欧美小视频 | 在线亚洲欧国产精品专区 | 欧美在线观看网站 | 午夜精品视频 | 苦瓜影院1313理论片 | 国产伦精一区二区三区 | 国内精品视频免费观看 | 亚洲欧美日韩色 | 国产精品三级在线观看 | 国产精品亚洲四区在线观看 | 欧美日韩免费在线观看 | 老色99久久九九精品尤物 |