前端Vue自定义加载中loading加载结束end组件 可用于分页展示 页面加载请求
阅读原文时间:2023年08月29日阅读:2

前端Vue自定义加载中loading加载结束end组件 可用于分页展示 页面加载请求, 请访问uni-app插件市场地址:https://ext.dcloud.net.cn/plugin?id=13219

效果图如下:

实现代码如下:

cc-paging

使用方法

<!-- 加载中用法 isLoading:是否加载 isEnd:是否结束加载 -->

<cc-paging :isLoading="true" :isEnd="false"></cc-paging>

<!-- 加载完成 isLoading:是否加载 isEnd:是否结束加载-->

<cc-paging :isEnd="true" :isLoading="false"></cc-paging>

HTML代码实现部分

<template>

<view class="content">

<view style="margin-left: 20px;"> 基本用法 </view>

<!-- 加载中用法 isLoading:是否加载 isEnd:是否结束加载 -->

<cc-paging :isLoading="true" :isEnd="false"></cc-paging>

<!-- 加载完成 isLoading:是否加载 isEnd:是否结束加载-->

<cc-paging :isEnd="true" :isLoading="false"></cc-paging>

<view style="margin-left: 20px;"> 动态使用用法 </view>

<!-- 加载中用法 -->

<cc-paging :isEnd="!isLoad" :isLoading="isLoad"></cc-paging>

<button @click="changeStatusClick">切换状态</button>

</view>

</template>

<script>

export default {

data() {

return {

isLoad: true

}

},

methods: {

changeStatusClick() {

this.isLoad = !this.isLoad;

}

}

}

</script>

<style>

page {

background: white;

}

.content {

display: flex;

padding-top: 29px;

flex-direction: column;

}

</style>

组件实现代码

<template>

&nbsp; &nbsp; <view class="paging">

&nbsp; &nbsp; &nbsp; &nbsp; <slot></slot>

&nbsp; &nbsp; &nbsp; &nbsp; <view class="loading" v-if="isLoading">

&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <view class="flexcenter">

&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <image lazyLoad src="https://qiniu-image.qtshe.com/qtsloading.gif"></image>

&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <view class="loadtips">加载中</view>

&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </view>

&nbsp; &nbsp; &nbsp; &nbsp; </view>

&nbsp; &nbsp; &nbsp; &nbsp; <view class="is-end" v-if="isEnd">我是有底线的哦~</view>

&nbsp; &nbsp; </view>

</template>

<script>

export default {

&nbsp; &nbsp; data() {

&nbsp; &nbsp; &nbsp; &nbsp; return {};

&nbsp; &nbsp; },

&nbsp; &nbsp; props: {

&nbsp; &nbsp; &nbsp; &nbsp; isEnd: {

&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; type: Boolean,

&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; default: false

&nbsp; &nbsp; &nbsp; &nbsp; },

&nbsp; &nbsp; &nbsp; &nbsp; isLoading: {

&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; type: Boolean,

&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; default: false

&nbsp; &nbsp; &nbsp; &nbsp; }

&nbsp; &nbsp; }

};

</script>

<style>

@import './index.css';

</style>