之前写的同样的代码,一点问题没有,为什么更新了开发工具之后,就提示:不能将类型“string”分配给类型nver,请高手指点下。如图:
代码如下:
wxml代码:
<view class="news" wx:for="{{newses}}">{{item}}</view>
<button class="loading" loading="true">上拉加载...</button>
ts代码:
Page({
/**
* 页面的初始数据
*/
data: {
sources:[
'今天礼拜四,天气很好,适合去钓鱼',
'今天礼拜四,天气很好,适合去钓鱼',
'今天礼拜四,天气很好,适合去钓鱼',
'今天礼拜四,天气很好,适合去钓鱼',
],
newses:[]
},
/**
* 生命周期函数--监听页面加载
*/
onLoad() {
var that = this;
setTimeout(function(){
var sources = that.data.sources;
var newses = [];
for(var index=0;index<10;index++){
var news = sources[index];
newses.push(news);
}
that.setData({
newses:newses
})
},1000);
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom() {
var that = this;
setTimeout(function(){
var newses = that.data.newses;
var newsesLength = newses.length;
var sources = that.data.sources;
var sourcesLength = that.data.sources.length;
var start = newsesLength;
var end = Math.min(start+9,sourcesLength-1);
for (var index = start;index <= end;index++){
var news = sources[index];
newses.push(news);
}
that.setData({
newses:newses
})
},1000)
}
开了ts类型检测吧