问题遇到的现象和发生背景
带参数跳转,用data-id传id参数过去,读取的时候id是有,但是undefined报错
问题相关代码,请勿粘贴截图
onLoad:function (options) {
console.log("options携带的值:",options)
let id=options.id
console.log("取id",id)
wx.cloud.database().collection("goods")
.doc(id)
.get()
.then( res =>{
this.setData({
item: res.data
})
})
.catch( err=> {
})
运行结果及报错内容
options携带的值: {id636050766253fa970542057a1f67ffa4: "undefined"}
demo1-1.js? [sm]:10 取id undefined
WAServiceMainContext.js:2 Error: collection.doc:fail -1 . docId must not be empty
at S (WASubContext.js?t=wechat&s=1649697738278&v=2.23.4:2)
at E (WASubContext.js?t=wechat&s=1649697738278&v=2.23.4:2)
at Object.doc (WASubContext.js?t=wechat&s=1649697738278&v=2.23.4:2)
at Mi.onLoad (demo1-1.js? [sm]:12)
at Mi. (WASubContext.js?t=wechat&s=1649697738278&v=2.23.4:2)
at Mi.i.callPageLifeTime (WASubContext.js?t=wechat&s=1649697738278&v=2.23.4:2)
at jt (WASubContext.js?t=wechat&s=1649697738278&v=2.23.4:2)
at WASubContext.js?t=wechat&s=1649697738278&v=2.23.4:2
at Wt (WASubContext.js?t=wechat&s=1649697738278&v=2.23.4:2)
at r. (WASubContext.js?t=wechat&s=1649697738278&v=2.23.4:2)(env: Windows,mp,1.05.2203251; lib: 2.23.4)
我的解答思路和尝试过的方法
每一步都用console看了,完全没头绪,传之前好好的,传过去就undefined了
我想要达到的结果
不知道哪一步错了