setData函数怎么用啊?
发布于 5 年前 作者 mintao 3592 次浏览 来自 问答

const app = getApp()

Page({

data: {

t: [

     ‘…/img/00.jpg’,

     ‘…/img/01.jpg’,

    ]

}

})

……

onLoad: function () {

t: [

     '../img/03.jpg',

     '../img/04.jpg',

    ]

var temp = t;

this.setData({

t: temp

})

}

运行后老是提示以下错误:

WAService.js:3 thirdScriptError

t is not defined;at pages/index/index page lifeCycleMethod onLoad function

ReferenceError: t is not defined

……

之前在这里提问过:https://developers.weixin.qq.com/blogdetail?action=get_post_info&docid=c71cd57f9c941a6baacbfee51e35ce7c&token=834490836&lang=zh_CN

搞这个函数搞了一个多星期了,都弄不明白,请哪位高手赐教!不胜感激!

2 回复

1楼正解,t变量没有声明

var t = [

‘…/img/03.jpg’,

‘…/img/04.jpg’,

]

var temp = t;

this.setData({

t: temp

})

回到顶部