我修改了我的問題以更具體。現在我不在乎期望的行爲,我只需要糾正語法錯誤獲取錯誤「property does not exist」
我正在學習this tutorial我在這段代碼中遇到一個錯誤。
嚴重性:偏移PagerserviceProvider '上類型不存在' '屬性': '錯誤'
消息'。
實際上,我對這三個變量有同樣的錯誤。
that.pageSize,that.offset,that.size
public async getPager(tableName:string,pageSize: number = 10) {
let pageSize = pageSize;
let offset = 0;
let limit = pageSize;
let size = await this.getTotal(tableName);
let that = this;
return {
initialPage:function(){
return new Promise((resolve,reject)=>{
var d = [];
that.executeSql(tableName,limit,offset).then((data)=>{
console.log(JSON.stringify(data));
for(var i = 0 ; i < data.rows.length ; i++)
{
d.push(data.rows.item(i));
}
resolve(d);
},(e)=>{
reject(e);
});
});
},
nextPage:function(){
if(that.offset <= that.size - that.pageSize)
{
that.offset += that.pageSize;
}
return new Promise((resolve,reject)=>{
var d = [];
that.executeSql(tableName,limit,offset).then((data)=>{
for(var i = 0 ; i < data.rows.length ; i++)
{
d.push(data.rows.item(i));
}
resolve(d);
},(e)=>{
reject(e);
});
});
}
};}
有什麼問題到底是什麼? –
[var that = this是什麼意思?]在JavaScript中是什麼意思?(https://stackoverflow.com/questions/4886632/what-does-var-that-this-mean-in-javascript) –
@Jeremy Thille我有一個錯誤在我的變量不承認,我猜其原因是選擇正確的情況下 – david