有关setdata问题?
发布于 6 年前 作者 ming48 10956 次浏览 来自 问答
console.log("befor:" + that.shareImg);
that.setData({ shareImg: res.tempFilePath });
console.log("after:" + that.shareImg);
console.log(res.tempFilePath);
输出如下:
befor:undefined
after:undefined
http://tmp/wxb4f060XXXXXX7.png
undefined

那个shareimg我还有赋初始值,然而一样是未定义?不懂

js里面怎么才能用全局变量,困扰了一周,求救

3 回复
that.data.shareImg

什么意思?你要获取data中的数据是that.data.shareImg

console.log("before:" + that.data.shareImg);
console.log("after:" + that.data.shareImg);
回到顶部