项目场景:
做一个项目,v-for循环数据库数据,使用uni-load-more,结果发现...
DOM中的列表却没有更新
解决方案:
根据网上教程,加了一个触底函数onReachBottom
,结果发现无论如何也更新不了DOM中的数据,最后将触底函数改成手动click触发。
更改后的相关代码如下
// 视图层
<view v-if="refresh" v-for="data in dataList" :key="data.id">{{ data.名称 }}
</view>
<view @click="test"><uni-load-more :status="status" :content-text="contentText" v-if="dataList.length > 0" />
</view>// 脚本层
<script>export default {data() {return {status: 'more',contentText: {contentdown: '点击加载更多~',contentrefresh: '加载中',contentnomore: '我是有底线的~'},}},methods: {test(){if (this.status != 'noMore') {console.log("触底")this.status = 'loading';this.ifBottomRefresh = true// 再次调用接口this.getList()} else {this.status ="noMore"}}}}
</script>