收藏
回答

.setData() 不能赋值,赋值失效?

 data: {
        activeIndex0,
        tempList'fangyi',
        data_access_token'',
        data: {
            tianqi'',
            wuti_image'/images/wuti.png',
            image'111',
        },
    },
transformBase64:function(imgSrc{
        var that = this;
        var FileSystemManager = wx.getFileSystemManager(); //创建文件管理器
        FileSystemManager.readFile({
            filePath: imgSrc,
            encoding'base64',
            successfunction(res{
                console.log('文件创建返回值')
                console.log(res.data)
                // var length = res.data.length;
                // console.log(length)
                var ssss = res.data
                that.setData({
                    "data.image": ssss //转码图片
                })
                console.log(that.data.data.image);//BASE64值
            }
        })
        console.log(that.data.data.image);//还是111

    },

怎么给data.data.image赋值

最后一次编辑于  2021-08-31
回答关注问题邀请回答
收藏

2 个回答

  • dreamhunter
    dreamhunter
    2021-08-31

    var ssss = res.data

    let data = that.data.data

    data.image = ssss


        that.setData({

            data: data 

        })

    试试,应该

    2021-08-31
    有用 1
    回复
  • 困难
    困难
    2021-08-31
    let newData=that.data.data
    newData.image=res.data;
    that.setData({
      data:newData
    })
    
    2021-08-31
    有用 1
    回复
登录 后发表内容