收藏
回答

数组有参,但是保存到云数据库就没参了。怎么回事? DetailsImages: this.data.

for (let l in this.data.DetailsImage) {
                    wx.cloud.uploadFile({
                        cloudPath: '商品/' + yonghu.xingming + new Date().getTime() + '.png',
                        filePath: this.data.DetailsImage[l].tempFilePath,
                    }).then(res => {
                        console.log(res)
                        this.data.DetailsImages.push(res.fileID)
                        console.log(this.data.DetailsImages)
                    })
                    
                }
                console.log(this.data.DetailsImages)  //时有值的
                wx.cloud.database().collection('commodity')
                .add({
                    data: {
                        Name: this.data.Name,
                        Money: this.data.Money,
                        SuggestMoney: this.data.SuggestMoney,
                        Supplier: this.data.supplier.Name,
                        Comment: this.data.Text,
                        HomeImage: this.data.HomeImage,
                        DetailsImages: this.data.DetailsImages,//保存到数据库就没值了。
                        Time: Date.now()
                    }
                }).then(res => {
                    console.log(res)
                    wx.hideLoading() //加载成功后隐藏
                })
回答关注问题邀请回答
收藏

2 个回答

  • showms
    showms
    2023-02-06

    异步问题,把这坨代码挪上去

    2023-02-06
    有用 2
    回复
  • 拾忆
    拾忆
    2023-02-04

    JS异步问题

    2023-02-04
    有用
    回复
登录 后发表内容