Vue:uni-app学习(十)-- 网络请求uni.request

vue

onLoad() {

this.getList()

},

getList() {

var data = {

column: \'id,post_id,title,author_name,cover,published_at\' //需要的字段名

};

uni.request({

url: \'https://unidemo.dcloud.net.cn/api/news\',

data: data,

success: data => {

if (data.statusCode == 200) {

let list = this.setTime(data.data);

list = this.reload ? list : this.listData.concat(list);

list.map(item => {

item.text = Math.floor(Math.random() * (1 - 20) + 20)

return item

})

this.listData = this.getRandomArrayElements(list, 3)

}

},

fail: (data, code) => {

console.log(\'fail\' + JSON.stringify(data));

}

});

},

以上是 Vue:uni-app学习(十)-- 网络请求uni.request 的全部内容, 来源链接: utcz.com/z/380144.html

回到顶部