How to modify the details of a single data in the Local Cache KEY

Recently, in the teacher’s review system, there is a “personal information” page has a editor to modify the mailbox function. It was very simple, and as a result, it took a long time.

The effect I want to achieve is to click on the mailbox below the picture below, then enter the right page, make a modification of the mailbox, click the submission to jump to the left page, and the mailbox also changes.

微信小程序如何修改本地缓存key中单个数据的详解 When you click ‘my’, I let it print from the console to the data passed in the Student cache, as follows:

{NO: “1635050601”, Name: “Zhang San”, SEX: “”, Email: “123@qq.com”, ClassID: “100000-1602”, …} ClassID: “100000-1602 “ClassName:” 16th PHP2 “DepartmentID:” 100000 “DepartmentName:” Software College “Name:” Zhang San “NO:” 1635050601 “SEX:” “
   
After I added an email, the background interface writes the method to save the value of the email directly to Student, but if you first add email, you can realize the email, you have to think about how to modify Email from the Student. .

// Form submit FormSubmit: function (e) {console.log (e.detail.value); var pwd = e.detail.value.pwd; var email = E.Detail.Value.email; if (pwd == ‘) {wx.showtoast ({Title:’ Password can’t be empty ‘, icon:’ None ‘, DURATION:1000,})} else if (email == ‘) {wx.showtoast ({title:’ mailbox can’t be empty ‘, icon:’ none ‘, duration: 1000,})} else {// post method Submit wx .Request ({URL: App.globalData.URL.BINDEMAIL, METHOD: “Post”, Data: {NO: this.Data.NO, PWD: PWD, Email: email}, header: {“content-type”: “:”: “:”: “:” Content-Type “:” Application / X-WWW-FORM-URLENCODED “}, Success: function (res) {// console.log (res) {wx.ShowToast ({Title: Res. Data) .msg, icon: ‘none’, duration: 1000,})} else {// Modify Email Var _student = wx.getStorageSync (‘student’); _student.email = email; wx.setStorageSync (‘studst’, _student) WX.ShowToast ({Title: Res. Data.msg, Icon: ‘Success “, Duration: 2000, Success: function () {settimeout (function () {Wx.relaunch ({url: ‘../myinfo/myinfo’,})}, 2000)}}}}},}}}}},}}}}},}}}}},}}}}},})}}}},})}}}},})}}}},})}}}},}}} Use the next method from the STUDENT to modify the value of Email.
 / / Modify Email Var _Student = wx.getStorageSync ('Student'); _Student.email = Email; wx.setStorageSync ('Student', _student);   
WX.setStorageSync (Key, Data)

Storing DATA stored in the key specified in the local cache, which overrides the content of the original key, this It is a synchronous interface.

WX.GetStorageSync (key)
Synchronize the contents corresponding to the specified Key synchronously from the local cache.
  If you have any questions or supplements, welcome friends to leave a message ~ Looking forward to learning with you, making progress together! ! !  
The above is the microcation applet to introduce the WeChat applet to modify the single data integration of the local cache Key, I hope to help everyone, if you have any questions, please leave a message, Xiaobian will reply to everyone in time. Thank you very much for your support of Tumi Cloud Website!

© Copyright Notice
THE END
Just support it if you like
like0
share
comment Grab the couch

Please log in to comment