Home > Mobile >  Update the data in the cloud development database WeChat small program, the data is updated, but the
Update the data in the cloud development database WeChat small program, the data is updated, but the

Time:11-28

This is the function of thumb up clickStatus to true when the thumb up heart icon will turn red, this is normal rendering, cloud development database on the number of thumb up already plus 1, but the page doesn't apply colours to a drawing, and print the result is also the result of the no 1, don't know what's the matter, for help, code and print the results are as follows:

CodePudding user response:


I tried it on WeChat small program is similar to the code, you are no problem of
 
Page ({
Data: {
Num: 1
},
OnLoad: function () {
Enclosing _update ()
},
_update: function () {
Var that=this
Var cnum=that. Data. Num + 1;
The console. The log (cnum)
Wx. GetSystemInfo ({
Success () {
The console. The log (that) the data) num)
That the setData ({
Num: cnum
})
The console. The log (that) the data) num)
}
})
}
})


The output is normal


Suggest you look at the place you quote the update function if you have any questions
(', for reference only)
And I also met with similar problems, also did not reply, here is my question link https://bbs.csdn.net/topics/392516002

CodePudding user response:

With monitoring function to print knew that can be used directly

CodePudding user response:

The building Lord, I encountered a similar situation when using the database, and then I use the two methods, one is the need of data to the front desk, using the form to submit, then use the form of data, this method is simple and crude, but also to see whether the program have the demand,
So I have to use the second method, below is the code I wrote, the hope can help you:
Async delorder (e) {
Var that=this
Const db=wx. Cloud. The database ();
Const _=db.com mand;
Var id=e. arget. Dataset. Id;

Let the list=await the collection (' getorders) where ({
_id: id
}). The get ();
Var oids=list. Data [0]. Orderid
The console. The log (oid)
//the orders in the flag to 0
The collection (' orders'). Doc (oid). Update ({
Data: {
Flag: 0
}
})
//getorders deleted this order
The collection (' getorders). Doc (id). Remove ({
Success: the function (res) {
Wx. ShowToast ({
Title: 'success! '
})
}
})

}

CodePudding user response:

I know, when I do the shopping cart, also encountered this kind of situation, to create a new variable in the data, first assignment to a variable, the variable is used to real-time display, is so simple, my latest blog has a code, you can go and see,

CodePudding user response:

Assignment problem, try: in=, or use this. Setdata statements
  • Related