1、给页面添加下拉刷新属性:
2、实现代码部分:
<template>
<view>
<view v-for="(item,index) in lists" :key="index">
{{item.name}}
</view>
</view>
</template>
<script>
export default{
data(){
return{
lists:[]
}
},
methods:{
getInfo(){
uni.request({
url:"http://localhost:8001/hello.json",
success:(res)=>{
this.lists=res.data.list
console.log(this.lists)
}
})
}
},
onPullDownRefresh() {//下拉刷新时调用
this.getInfo()
}
}
</script>
<style>
</style>