本文章主要讲述uniapp中get请求如何用
在view中显示中的内容:
<view class="word1" v-for="(item,index) in testName">
<view class="text-box" scroll-y="true">
<view class="alarm-name">告警名称:{{item.name}}</view>
<view class="alarm-content">告警内容:{{item.content}}</view>
</view>
</view>
onShow生命周期:
监听页面显示。页面每次出现在屏幕上都触发,包括从下级页面点返回露出当前页面。
onShow | 当 uni-app 启动,或从后台进入前台显示 |
onShow:function(options){
uni.request({
url: 'http://',
method: 'GET',
data: {},
success: res => {
console.log(res);
//取后端接口的数据【json格式】
this.testName = res.data.data.pageView.list.map((value,index)=>{
return {
"name":value.alarmName,
"content":value.alarmContent,
"id":value.alarmId
}
});
},
fail: () => {},
complete: () => {}
});
},