原理很简单定义两个数组用数组用数组替换的思想在给一个if循环做如下图
<template>
<view class="">
<view class="" v-for="(item,index) in info">
<h5>{{item.name}}</h5><h5>{{item.id}}</h5><h5>{{item.age}}</h5>
<button type="default" @click="jz">加载更多</button>
</view>
</view>
</template>
<script>
export default {
data() {
return {
ww:"",
// www:true,
// www:true
info:[{
id:1,
name:"嗡嗡嗡",
age:"17"
}],
info1:[{
id:1,
name:"嗡嗡嗡",
age:"17"
}]
}
},
methods: {
jz(){
console.log("ok")
let arr=this.info.length
console.log(arr)
this.info.push(this.info1[arr - 1])
if(arr===1){
console.log("ok")
}else{
console.log('继续加载')
}
}
}
}
</script>