In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly introduces "WeChat Mini Programs reported wrong this.setData is not a function how to solve". In daily operation, I believe that many people have doubts about how WeChat Mini Programs reported wrong this.setData is not a function how to solve the problem. The editor consulted all kinds of materials and sorted out simple and easy-to-use operation methods. I hope it will be helpful to answer the doubt of "WeChat Mini Programs reported wrong this.setData is not a function how to solve". Next, please follow the editor to study!
WeChat Mini Programs reported an error: this.setData is not a function
The code defined in page is as follows, and the code will report an error: this.setData is not a function
PasteEncryptedText:function () {let decryptedPass = this.data.decryptedPassword; if (decryptedPass = ='') {wx.showToast ({title: 'please enter the decryption password first', mask: true, success: function (res) {setTimeout (function () {wx.hideToast ();}, 4000);},}); return } else {wx.getClipboardData ({success: function (res) {if (res.data = ='') {wx.showToast ({title: 'clipboard has no content', mask: true, success: function (res) {setTimeout (function () {wx.hideToast ();}, 4000);},})} else {console.log (decryptedPass); console.log (res.data) This.setData ({encryptedTextDecode: res.data, originalTextDecode: desEncryptedDecrypted.decrypt (res.data, decryptedPass),}); console.log (this.data.originalTextDecode);};}
Problem analysis: another function wx.showToast () is nested in the function pasteEncryptedText (), while setData () is called in wx.showToast (), when this.setData ()
The this in is not page, but the object wx.showToast ()
Solution:
Save the this object at the beginning of the function pasteEncryptedText (): let that = this;pasteEncryptedText:function () {let decryptedPass = this.data.decryptedPassword;let that = this; if (decryptedPass = =') {wx.showToast ({title: 'please enter the decryption password first', mask: true, success: function (res) {setTimeout (function () {wx.hideToast ();}, 4000);},},}); return } else {wx.getClipboardData ({success: function (res) {if (res.data = ='') {wx.showToast ({title: 'clipboard has no content', mask: true, success: function (res) {setTimeout (function () {wx.hideToast ();}, 4000);},})} else {console.log (decryptedPass); console.log (res.data) That.setData ({encryptedTextDecode: res.data, originalTextDecode: desEncryptedDecrypted.decrypt (res.data, decryptedPass),}); console.log (that.data.originalTextDecode);});} at this point, the study on "how to solve WeChat Mini Programs's error this.setData is not a function" is over, hoping to solve everyone's doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 243
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.