當fetch通路伺服器傳回資料觸發success方法時,發現在success方法中無法使用this下的外部元素與涵數解決方法:const that = this
const that = this //傳遞this到内部使用that代替
fetch.fetch({
url: urls,
data: {
id: 'LocalNews',
ajax: 'json'
},
responseType: 'json',// 支援傳回類型是text、json、file和arraybuffer,預設傳回字元串文本。
success: function (ret) {
memList = memList.concat(ret.data.data)
const list = memList.splice(0, that.size)
that.productList = that.productList.concat(list)//在内部使用that來通路外部内容
}
}