<span id="mktg5"></span>

<i id="mktg5"><meter id="mktg5"></meter></i>

        <label id="mktg5"><meter id="mktg5"></meter></label>
        最新文章專題視頻專題問答1問答10問答100問答1000問答2000關鍵字專題1關鍵字專題50關鍵字專題500關鍵字專題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關鍵字專題關鍵字專題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的解決辦法

        來源:懂視網 責編:小采 時間: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
        推薦度:
        導讀微信小程序報錯: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: '剪貼板沒有內容', 
         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); 
         } 
         } 
         }); 
         } 
         } 
        

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

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

        解決方法:

        <strong> 在函數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: '剪貼板沒有內容', 
         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>); 
         } 
         } 
         }); 
        } 
        
        

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

        聲明:本網頁內容旨在傳播知識,若有侵權等問題請及時與本網聯系,我們將在第一時間刪除處理。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亚洲男女激情在线观看| 久草免费福利视频| 国产JIZZ中国JIZZ免费看| 亚洲精品一级无码鲁丝片| 成年免费a级毛片| 亚洲无线观看国产精品| 国内精品免费视频精选在线观看 | 不卡视频免费在线观看| 亚洲午夜国产片在线观看| 美女被免费网站91色| 久久久亚洲精品视频| 69av免费观看| 亚洲欧洲免费无码| 成人免费区一区二区三区| 永久免费视频v片www| 亚洲国产精品久久久久网站 | 亚洲av永久无码精品三区在线4| 亚洲一区二区三区免费| 伊人久久大香线蕉亚洲| 久久青草免费91观看| 亚洲一线产区二线产区精华| 在线观看免费宅男视频| 亚洲国产精品成人综合色在线| 中国xxxxx高清免费看视频| 久久亚洲国产最新网站| 免费a级毛片无码a∨性按摩| 黄色视屏在线免费播放| 又粗又硬免费毛片| 久久国产免费观看精品| 国产精品亚洲精品日韩已方| 亚洲成AV人片在WWW| 亚洲啪啪AV无码片| 国产免费内射又粗又爽密桃视频| 日韩精品无码人妻免费视频| 亚洲免费日韩无码系列| 亚洲国产成人久久一区久久| 91九色视频无限观看免费| 狠狠色伊人亚洲综合成人| 一区二区免费电影| 亚洲大香伊人蕉在人依线|