多应用+插件架构,代码干净,二开方便,首家独创一键云编译技术,文档视频完善,免费商用码云13.8K 广告
| 下载地址 | | --- | | https://ext.dcloud.net.cn/plugin?id=4489 | * 模板调用 ~~~ <template> <view> <t-refresh ref="refresh" @refresh="refresh" @loadMore="loadMore" :loadingType="loadingType"> <template slot="content"> <view class="refresh-item" v-for="(item,index) in number" :key="index"> {{index}} </view> </template> </t-refresh> <t-toast ref="toast"></t-toast> </view> </template> ~~~ * script调用 ~~~ import tRefresh from "@/components/t-refresh/t-refresh.vue" import tToast from "@/components/t-toast/t-toast.vue" export default { components:{tRefresh,tToast}, data() { let arr = {}; arr.loadingType = 0; arr.number = 20; return arr; }, onLoad() { }, methods: { // 加载更多 loadMore: async function() { //loadingType: 0.数据未加载完 1.数据全部加载完了 2.数据加载中 if(this.loadingType==0){ this.loadingType=2 //模拟数据请求 setTimeout(()=>{ this.number=30 this.loadingType=1 },1000) } }, //刷新 refresh(e){ //模拟数据请求 setTimeout(()=>{ this.$refs.refresh.endRefresh() this.number=20 this.loadingType=0 this.$refs.toast.show('success','更新成功') },1000) }, } } ~~~ * style调用 ~~~ .refresh-item{ height:80upx; line-height: 80upx; text-align: center; border-bottom: 1upx solid #F4F4F4; } ~~~