Home > Mobile >  Why don't setData take the value?
Why don't setData take the value?

Time:09-26

//pages/goodsdetail goodsdetail. Js
Const app=getApp ()
Const db=wx. Cloud. The database ();

Page ({

Data: {
Id: ", "
GoodsDetailInfo: ""
},

/* *
* life cycle function - listening page load
*/
OnLoad: function (options) {
Var that=this
//clicks from increasing
Const ins=the collection (' yk_product). Doc (options. Id)
Ins. Update ({
Data: {
Product_count: db.com mand. Inc (1)
}

})
//commodity data
Ins. Get ({

Success (res) {
The console. The log (res) data)
That the setData ({
GoodsDetailInfo: res. Data
})
The console. The log (" success ", res. Data)
The console. The log (" success ", goodsDetailInfo)

}

})

},




1, why the console goodsDetailInfo. Log out? Also not receive in WXML value,
The console. The log (res) data) can show the data,

2,
Product_count: db.com mand. Inc (1) there was something wrong with this sentence? Why cloud database product_count (number) from growing?

CodePudding user response:

Top,

CodePudding user response:

First define the var that=this; Then the console. The log (" success ", goodsDetailInfo) this sentence you to the console. The log (" success ", that. Data. GoodsDetailInfo)
  • Related