【uniapp】页面下拉刷新

news2025/2/24 18:55:55

目录

一、全局

二、局部

1、一个页面一个下拉刷新

2、一个页面多个下拉刷新(切换时滚动条回到顶部)

3、一个页面多个下拉刷新(切换时恢复滚动条位置)


一、全局

修改pages.json的"enablePullDownRefresh": true,

{
    "pages": [ 
        {
            "path": "pages/tabBar/dashboard/index",
            "style": {
                "navigationBarTitleText": "项目管理",
                "enablePullDownRefresh": true,
                "navigationBarTextStyle": "white",
                "navigationBarBackgroundColor": "#374449"
            }
        },
    ],
    "globalStyle": {
        "navigationBarTextStyle": "black",
        "navigationBarTitleText": "管理平台",
        "navigationBarBackgroundColor": "#F8F8F8",
        "backgroundColor": "#F8F8F8"
    },
}

页面中(onPullDownRefresh 处理函数和onLoad等生命周期函数同级 )

export default {
    data() {
            return {
                productList: [], //列表
                query: {
                    keyword: '', //搜索框
                    pagesize: 10,
                    page: 1,
                },
                total: 0, //总条数
                showTotal: true, //是否显示“下拉加载更多~”
            }
        },
        // 下拉刷新
        onPullDownRefresh() {
            var allTotal = this.query.page * this.query.pagesize
            //this.page为加载次数,this.pageSize为每一次加载的数据条数
            if (allTotal < this.total) {
                //this.total为请求数据的总条数。只要现有条数小于总条数就执行一下代码
                this.showTotal = true;
                this.query.page++;
                //加载次数递加
                this.getlist() //请求更多数据列表
            } else {
                this.showTotal = false;
            }
            uni.stopPullDownRefresh();//停止刷新
        },
}

二、局部

我使用的是插件https://ext.dcloud.net.cn/plugin?id=343

插件文档https://www.mescroll.com/uni.html 

这个插件的还有相对应的案例我已经下载下来了,到时候直接放到编辑器打开即可 链接:https://pan.baidu.com/s/1q6IB-mCdCQqcvKaZmzJtcg 提取码:e66j

我的需求是顶部内容固定不动,列表下拉刷新(没有页码,数据一次性展示) 

1、一个页面一个下拉刷新

页面使用

<template>
	<view class="details-container">
		<view class="example-body">
			<view v-for="(item,index) in tags" :key="index"
				:class="whichSelected===index?'stateBtnSelected':'stateBtnNoselect'" :circle="true"
				@click="selectState(index)">{{item}}</view>
		</view>

		<view class="center" v-show="tabs===0">
            <!-- 第一步:参数一个都不能少,三个事件是固定的 -->
			<mescroll-body ref="mescrollRef" @init="mescrollInit" @down="downCallback" @up="upCallback"
				:down="downOption" :up="upOption">
				<Tree :list="list" :local='local'></Tree>
			</mescroll-body>
		</view>
	</view>
</template>

<script>
	import Tree from '../../components/Tree/index.vue'
    //第二步:引入
	import MescrollMixin from "@/uni_modules/mescroll-uni/components/mescroll-uni/mescroll-mixins.js";
	export default {
		mixins: [MescrollMixin],//第二步:引入
		name: 'Details',
		components: {
			Tree,
		},
		data() {
			return {
				tags: [],
				whichSelected: 0, //标签
				tabs: 0, //标签对应页面
				list: [], //列表
				content: {}, //上一页数据
				local: '',

                //第三步:数据
				//downOption和upOption的参数配置在mescroll-uni.js中查看
				downOption: {
					auto: false // 不自动加载 (mixin已处理第一个tab触发downCallback)
				},
				upOption: {
                   use: false, // 是否启用上拉加载; 默认true
                   auto: false
                }
			};
		},
		onLoad(e) {
			let that = this
			this.local = uni.getLocale()
			this.content = JSON.parse(e.item)
			if (this.local === 'zh-Hans') {
				uni.setNavigationBarTitle({
					title: that.content.Name,
				})
			} else {
				uni.setNavigationBarTitle({
					title: that.content.Name_EN,
				})
			}
			this.GetFileListById()
			this.tags.push(this.$t('word.whole'))
		},
		methods: {
             //第三步:事件
			/*下拉刷新的回调 */
			downCallback() {
                let that = this
				this.api.GetFileListById({ //调用接口
					datagramsid: that.content.Id
				}).then(res => {
					that.list = res.data.Data
                    this.$nextTick(() => {
					   this.mescroll.endSuccess(this.list.length)
				    })
				}).catch(() => {
					//联网失败, 结束加载
					this.mescroll.endErr();
				})
		
			},
            /*上拉 */
			upCallback() {
				 let that = this
				this.api.GetFileListById({ //调用接口
					datagramsid: that.content.Id
				}).then(res => {
					that.list = res.data.Data
                   let curPageLen = this.list.length;
				   // 接口返回的是否有下一页 (true/false)
				   let hasNext = false;
				   setTimeout(() => {
					 this.mescroll.endSuccess(curPageLen, hasNext)
				   }, 20)
				}).catch(() => {
					//联网失败, 结束加载
					this.mescroll.endErr();
				})
			},
			GetFileListById() {
				let that = this
				this.api.GetFileListById({
					datagramsid: that.content.Id
				}).then(res => {
					that.list = res.data.Data
				})
			},
		}
	}
</script>

2、一个页面多个下拉刷新(切换时滚动条回到顶部)

多页tabs切换,实现下拉刷新(没有页码,数据一次性展示) ,每个tab页面内容都不相同

插件上说不能使用v-if,是因为使用了v-if就不能实现切换tabs恢复滚动条位置(v-if是创建和销毁,v-show是隐藏和显示)。

但是我使用官方示例的代码重新加载列表数据或其他的方法都不行

// 详情返回列表,重新加载列表数据
	onShow() {
		this.canReset && this.mescroll.resetUpScroll() // 重置列表数据为第一页  
		this.canReset && this.mescroll.scrollTo(0,0) // 重置列表数据为第一页时,建议把滚动条也重置到顶部,避免无法再次翻页的问题  
		this.canReset = true // 过滤第一次的onShow事件,避免初始化界面时重复触发upCallback, 无需配置auto:false
		
		// 注意: 子组件没有 onShow 的生命周期, 所以
		// 对于 mescroll-more.vue 和 mescroll-swiper.vue 的返回刷新, 需更新 1.3.3 版本, 且参考对应示例的onShow写法
	}

若是换成mescroll-body,并且使用v-show会出现切换tabs滚动条位置一致,也就是上一页滚动条在哪,下一页的滚动条就在哪。找了好久也不知道问题出在哪里,最后我只能写成组件使用mescroll-uni+v-if的方法。

但是你们使用还是要先根据官网来做,如果出现我这样的问题再安装我的方法做 

第一步:创建组件放置tabs所对应的页面(这里我就只写一个子组件的格式)

pages/word/components/all.vue

注意:子组件使用onShow、onLoad无效,需要写在created中才行 

<template>
	<!-- 不能用v-if (i: 每个tab页的专属下标;  index: 当前tab的下标; 申明在 MescrollMoreItemMixin )-->
	<view v-if="i === index">
		<mescroll-uni ref="mescrollRef0" top="92" @init="mescrollInit" @down="downCallback" @up="upCallback"
			:down="downOption" :up="upOption">
			<!-- 数据列表 -->
			<Tree :list="list" :local='local'></Tree>
		</mescroll-uni>
	</view>
</template>

<script>
	import Tree from '@/components/Tree/index.vue'
	import MescrollMixin from "@/uni_modules/mescroll-uni/components/mescroll-uni/mescroll-mixins.js";
	import MescrollMoreItemMixin from "@/uni_modules/mescroll-uni/components/mescroll-uni/mixins/mescroll-more-item.js";

	export default {
		mixins: [MescrollMixin, MescrollMoreItemMixin], // 使用mixin (在main.js注册全局组件)
		components: {
			Tree,
		},
		props: {
			i: Number, // 每个tab页的专属下标 (除了支付宝小程序必须在这里定义, 其他平台都可不用写, 因为已在MescrollMoreItemMixin定义)
			index: { // 当前tab的下标 (除了支付宝小程序必须在这里定义, 其他平台都可不用写, 因为已在MescrollMoreItemMixin定义)
				type: Number,
				default () {
					return 0
				}
			},
			tabs: { // 为了请求数据,演示用,可根据自己的项目判断是否要传
				type: Array,
				default () {
					return []
				}
			}
		},
		data() {
			return {
				list: [], //下载列表
				local: '',

				downOption: {
					auto: false // 不自动加载 (mixin已处理第一个tab触发downCallback)
				},
				upOption: {
                   use: false, // 是否启用上拉加载; 默认true
                   auto: false
                }
			}
		},
		created() {
			this.local = uni.getLocale()
		},
		methods: {
			/*上拉加载的回调: 其中page.num:当前页 从1开始, page.size:每页数据条数,默认10 */
			downCallback() {
				this.mescroll.resetUpScroll()
			},
			upCallback(page) {
				let pageNum = page.num
				this.api.GetFileTreeJson().then(res => {
					// console.log(res.data.Data)
					this.list = res.data.Data
					this.mescroll.endByPage(this.list.length, 1);
					//设置列表数据
					if (page.num == 1) this.list = []; //如果是第一页需手动制空列表
					this.list = this.list.concat(res.data.Data); //追加新数据
				}).catch(() => {
					//联网失败, 结束加载
					this.mescroll.endErr();
				})
			},
		}
	}
</script>

pages/word/components/downitem.vue和上一个组件一致,只不过数据组件不一致,多了一个获取列表的方法给父组件使用

<template>
	<!-- 不能用v-if (i: 每个tab页的专属下标;  index: 当前tab的下标; 申明在 MescrollMoreItemMixin )-->
	<view v-if="i === index">
		<mescroll-uni ref="mescrollRef1" @init="mescrollInit" top="92" :down="downOption" @down="downCallback"
			:up="upOption" @up="upCallback" @emptyclick="emptyClick">
			<DownTree :records="records" :local='local'></DownTree>
		</mescroll-uni>
	</view>
</template>

<script>
	import DownTree from '@/components/DownTree/index.vue'
	import MescrollMixin from "@/uni_modules/mescroll-uni/components/mescroll-uni/mescroll-mixins.js";
	import MescrollMoreItemMixin from "@/uni_modules/mescroll-uni/components/mescroll-uni/mixins/mescroll-more-item.js";
	export default {
		mixins: [MescrollMixin, MescrollMoreItemMixin],
		components: {
			DownTree
		},
		props: {
			i: Number, // 每个tab页的专属下标 (除了支付宝小程序必须在这里定义, 其他平台都可不用写, 因为已在MescrollMoreItemMixin定义)
			index: { // 当前tab的下标 (除了支付宝小程序必须在这里定义, 其他平台都可不用写, 因为已在MescrollMoreItemMixin定义)
				type: Number,
				default () {
					return 0
				}
			},
			tabs: { // 为了请求数据,演示用,可根据自己的项目判断是否要传
				type: Array,
				default () {
					return []
				}
			}
		},
		data() {
			return {
				records: [], //下载列表
				local: '',

				downOption: {
					auto: false // 不自动加载 (mixin已处理第一个tab触发downCallback)
				},
				upOption: {
                   use: false, // 是否启用上拉加载; 默认true
                   auto: false
                }
			}
		},
		created() {
			this.local = uni.getLocale()
		},
		methods: {
			/*下拉刷新的回调 */
			downCallback() {
				this.mescroll.resetUpScroll()
			},
			upCallback(page) {
				let pageNum = page.num
				this.api.GetWxUserDownloadList().then(res => {
					this.records = res.data.Data
					this.mescroll.endByPage(this.records.length, 1);
					//设置列表数据
					if (page.num == 1) this.records = []; //如果是第一页需手动制空列表
					this.records = this.records.concat(res.data.Data); //追加新数据
				}).catch(() => {
					//联网失败, 结束加载
					this.mescroll.endErr();
				})
			},
			getrecords() {
				this.api.GetWxUserDownloadList().then(res => {
					this.records = res.data.Data
					this.mescroll.endByPage(this.records.length, 1);
					//设置列表数据
					if (page.num == 1) this.records = []; //如果是第一页需手动制空列表
					this.records = this.records.concat(res.data.Data); //追加新数据
				}).catch(() => {
					//联网失败, 结束加载
					this.mescroll.endErr();
				})
			},
		}
	}
</script>

第三步:在页面中使用pages/word/components/index.vue

<template>
	<view class="word-container">
		<view class="example-body">
			<view v-for="(item,index) in tags" :key="index"
				:class="tabIndex===index?'stateBtnSelected':'stateBtnNoselect'" :circle="true"
				@click="tabChange(index)" @input="changeload" v-model="tabIndex">{{item}}</view>
		</view>
		<!-- 全部 -->
		<mescroll-all ref="mescrollItem0" :i="0" :index="tabIndex" :tabs="tags">
		</mescroll-all>
		<!-- 下载记录 -->
		<MescrollDown ref="mescrollItem1" :i="1" :index="tabIndex" :tabs="tags">
		</MescrollDown>
	</view>
</template>

<script>
	import MescrollAll from "./components/all.vue";
	import MescrollDown from "./components/downitem.vue";

	import MescrollMoreMixin from "@/uni_modules/mescroll-uni/components/mescroll-uni/mixins/mescroll-more.js";
	export default {
		mixins: [MescrollMoreMixin],
		name: 'Word',
		components: {
			MescrollDown,
			MescrollAll,
		},
		data() {
			return {
				tags: [],
				local: '',

				tabIndex: 0,//标签对应页面
			};
		},
		onLoad() {
			this.tags.push(this.$t('word.whole'), this.$t('word.download'))
			uni.setNavigationBarTitle({
				title: this.$t('pages.word'),
			})
		},
		onShow() {
			this.tabIndex = this.$store.state.tabs
			this.local = uni.getLocale()
			if (this.whichSelected === 1) {
				const Token = uni.getStorageSync('GetPhone_Token')
				if (Token) {
                    //点击下载列表tab的时候要判断有没有token,没有就要跳转到登录页,我登录成功后返回到这一页
                    //若是我不调用子组件的方法也就是获取列表数据,会出现一直显示加载中,所以我这里调用了方法,下面的标签切换同理
					this.$refs.mescrollItem1.getrecords()
				} else {
					uni.navigateTo({
						url: '/pages/login/index'
					});
				}
			} 
		},
		methods: {
			// 标签切换
			tabChange(index) {
				this.whichSelected = index
				this.tabIndex = index
				this.$store.commit('SET_TABS', index)
				if (this.tabIndex === 1) {
					const Token = uni.getStorageSync('GetPhone_Token')
					if (Token) {
						this.$refs.mescrollItem1.getrecords()
					} else {
						uni.navigateTo({
							url: '/pages/login/index'
						});
					}
				} 
			},
		}
	}
</script>

<style lang="scss">
	.vue-ref {
		padding: 0 !important;
	}
	.word {
		&container {
			position: relative;
		}
	}
	.left {
		display: flex;
		margin: 10px;
	}
	.example-body {
		display: flex;
		padding: 10px 20px;
		background-color: #fff;
		width: 100%;
		position: fixed;
		z-index: 2;
	}
	.center {
		position: absolute;
		top: 45px;
		width: 100%;
		// height: 100%;
		border-top: 1px solid #e5e5e5;
	}
	.stateBtnSelected {
		background-color: #bbe5ff;
		color: #1480cd !important;
		border-radius: 20px;
		font-size: 14px;
		height: 25px;
		line-height: 25px;
		// width: 60px;
		margin: 0 5px;
		padding: 0 15px;
		text-align: center;
	}
	.stateBtnNoselect {
		background-color: transparent;
		color: #8f939c !important;
		border: none !important;
		font-size: 14px;
		height: 25px;
		line-height: 25px;
		// width: 60px;
		margin: 0 5px;
		padding: 0 15px;
		text-align: center;
	}
	.slot-image {
		width: 30px;
		height: 30px;
	}
	.slot-box {
		margin-right: 10px;
	}
	.uni-list-item__container {
		align-items: center !important;
		line-height: 20px;
	}
</style>

3、一个页面多个下拉刷新(切换时恢复滚动条位置)

如果tabs对应内容分别封装成各自组件,子组件封装的时候使用mescroll-uni,并且使用v-show会出现当列表数据多页时切换tabs,恢复滚动条位置不准确并且会触发上拉这样的问题。但是如果我把他放在一个组件里就不会产生这样的问题

 第一步:组件pages/word/components/all.vue

Tree和DownTree组件使用的是uni-list的自定义插槽,不知道为啥我使用uni-list-item就会触发一次上拉,之后就不会了,但是不使用就不会触发

<template>
	<view class="word-container">
		<!-- 使用这个切换tabs的时候,会触发上拉一次,之后就不会再触发了 -->
		<!-- <uni-list>
			<uni-list-item v-for="(item,index) in records" :key='index'
				:title="local==='zh-Hans'?item.filename:item.filename_EN" thumb-size="lg"
				:rightText="item.DownloadTime">
				<template v-slot:header>
					<view class="slot-box">
						<image v-if="item.fileExt==='.mp4'" class="slot-image" src="/static/shipin_lvhangyingxiang.png"
							mode="widthFix">
						</image>
						<image v-else-if="item.fileExt==='.pdf'" class="slot-image" src="/static/pdfwenjian.png"
							mode="widthFix">
						</image>
						<image v-else class="slot-image" src="/static/a-wenjianjiawenjian.png" mode="widthFix">
						</image>
					</view>
				</template>
			</uni-list-item>
		</uni-list> -->
		<uni-list v-for="(item,j) in records" :key='j'>
			<view :border="none" :padding="0" :spacing="0" style="padding:0" :is-shadow="false" :isFull="true">
				<view class="card-title" style="display: flex;justify-content: space-between;">
					<view>
						<image v-if="item.fileExt==='.mp4'" class="slot-image" src="/static/shipin_lvhangyingxiang.png"
							mode="widthFix">
						</image>
						<image v-else-if="item.fileExt==='.pdf'" class="slot-image" src="/static/pdfwenjian.png"
							mode="widthFix">
						</image>
						<image v-else class="slot-image" src="/static/a-wenjianjiawenjian.png" mode="widthFix">
						</image>
					</view>
					<view class="title-box"
						style="display: flex;justify-content: space-between;width: 100%;align-items: center;">
						<view class="">{{local==='zh-Hans'?item.filename:item.filename_EN}}
						</view>
						<view class="">{{item.DownloadTime}}</view>
					</view>
				</view>
			</view>
		</uni-list>
	</view>
</template>
<template>
	<!-- 不能用v-if (i: 每个tab页的专属下标;  index: 当前tab的下标; 申明在 MescrollMoreItemMixin )-->
	<view v-show="i === index">
		<mescroll-uni :ref="'mescrollRef'+i" top="92" @init="mescrollInit" @down="downCallback" @up="upCallback"
			:down="downOption" :up="upOption">
			<!-- 数据列表 -->
            <!-- tab为0的时候 -->
			<Tree v-if="index===0" :list="list" :local='local'></Tree>
            <!-- tab为1的时候 -->
			<DownTree v-else :records="records" :local='local'></DownTree>
		</mescroll-uni>
	</view>
</template>

<script>
	import DownTree from '@/components/DownTree/index.vue'
	import Tree from '@/components/Tree/index.vue'
	import MescrollMixin from "@/uni_modules/mescroll-uni/components/mescroll-uni/mescroll-mixins.js";
	import MescrollMoreItemMixin from "@/uni_modules/mescroll-uni/components/mescroll-uni/mixins/mescroll-more-item.js";

	export default {
		mixins: [MescrollMixin, MescrollMoreItemMixin], // 使用mixin (在main.js注册全局组件)
		components: {
			Tree,
			DownTree
		},
		props: {
			i: Number, // 每个tab页的专属下标 (除了支付宝小程序必须在这里定义, 其他平台都可不用写, 因为已在MescrollMoreItemMixin定义)
			index: { // 当前tab的下标 (除了支付宝小程序必须在这里定义, 其他平台都可不用写, 因为已在MescrollMoreItemMixin定义)
				type: Number,
				default () {
					return 0
				}
			},
			tabs: { // 为了请求数据,演示用,可根据自己的项目判断是否要传
				type: Array,
				default () {
					return []
				}
			}
		},
		data() {
			return {
				list: [], //下载列表
				local: '',
				records: [], //下载列表

				downOption: {
					auto: false // 不自动加载 (mixin已处理第一个tab触发downCallback)
				},
				upOption: {
                   use: false, // 是否启用上拉加载; 默认true
                   auto: false
                }
			}
		},
		created() {
			this.local = uni.getLocale()
		},
		methods: {
			/*上拉加载的回调: 其中page.num:当前页 从1开始, page.size:每页数据条数,默认10 */
			downCallback() {
				this.mescroll.resetUpScroll()
			},
			upCallback(page) {
				if (this.index === 0) {
					let pageNum = page.num
					this.api.GetFileTreeJson().then(res => {
						// console.log(res.data.Data)
						this.list = res.data.Data
						this.mescroll.endByPage(this.list.length, 1);
						//设置列表数据
						if (page.num == 1) this.list = []; //如果是第一页需手动制空列表
						this.list = this.list.concat(res.data.Data); //追加新数据
					}).catch(() => {
						//联网失败, 结束加载
						this.mescroll.endErr();
					})
				} else {
					this.api.GetWxUserDownloadList().then(res => {
						// console.log(res.data.Data)
						this.records = res.data.Data
						this.mescroll.endByPage(this.records.length, 1);
						//设置列表数据
						if (page.num == 1) this.records = []; //如果是第一页需手动制空列表
						this.records = this.records.concat(res.data.Data); //追加新数据
					}).catch(() => {
						//联网失败, 结束加载
						this.mescroll.endErr();
					})
				}

			},
			// 文件列表
			GetFileTreeJson() {
				this.api.GetFileTreeJson().then(res => {
					// console.log(res.data.Data)
					this.list = res.data.Data
					this.mescroll.endByPage(this.list.length, 1);
					//设置列表数据
					if (page.num == 1) this.list = []; //如果是第一页需手动制空列表
					this.list = this.list.concat(res.data.Data); //追加新数据
				}).catch(() => {
					//联网失败, 结束加载
					this.mescroll.endErr();
				})
			},
			getrecords() {
				this.api.GetWxUserDownloadList().then(res => {
					// console.log(res.data.Data)
					this.records = res.data.Data
					this.mescroll.endByPage(this.records.length, 1);
					//设置列表数据
					if (page.num == 1) this.records = []; //如果是第一页需手动制空列表
					this.records = this.records.concat(res.data.Data); //追加新数据
				}).catch(() => {
					//联网失败, 结束加载
					this.mescroll.endErr();
				})
			},
		}
	}
</script>

第二步:页面使用pages/word/components/index.vue

<template>
	<view class="word-container">
		<view class="example-body">
			<view v-for="(item,index) in tags" :key="index"
				:class="tabIndex===index?'stateBtnSelected':'stateBtnNoselect'" :circle="true"
				@click="tabChange(index)" @input="changeload" v-model="tabIndex">{{item}}</view>
		</view>

		<mescrollItem0 ref="mescrollItem0" :i="0" :index="tabIndex" :tabs="tags">
		</mescrollItem0>
		<mescrollItem0 ref="mescrollItem1" :i="1" :index="tabIndex" :tabs="tags">
		</mescrollItem0>
	</view>
</template>

<script>
	import mescrollItem0 from "./components/all.vue";
	import mescrollItem1 from "./components/downitem.vue";

	// import MescrollMixin from "@/uni_modules/mescroll-uni/components/mescroll-uni/mescroll-mixins.js";
	import MescrollMoreMixin from "@/uni_modules/mescroll-uni/components/mescroll-uni/mixins/mescroll-more.js";
	export default {
		mixins: [MescrollMixin],
		name: 'Word',
		components: {
			mescrollItem0,
			mescrollItem1,
		},
		data() {
			return {
				tags: [],
				list: [],
				records: [], //下载列表
				local: '',

				tabIndex: 0,//标签对应页面
			};
		},
		onLoad() {
			this.tags.push(this.$t('word.whole'), this.$t('word.download'))
			uni.setNavigationBarTitle({
				title: this.$t('pages.word'),
			})
		},
		onShow() {
			this.whichSelected = this.$store.state.tabs
			this.tabIndex = this.$store.state.tabs
			this.local = uni.getLocale()
			if (this.whichSelected === 1) {
				const Token = uni.getStorageSync('GetPhone_Token')
				if (Token) {
					this.$refs.mescrollItem1.getrecords()
				} else {
					uni.navigateTo({
						url: '/pages/login/index'
					});
				}
			} 
		},
		methods: {
			// 标签切换
			tabChange(index) {
				this.whichSelected = index
				this.tabIndex = index
				this.$store.commit('SET_TABS', index)
				if (this.tabIndex === 1) {
					const Token = uni.getStorageSync('GetPhone_Token')
					if (Token) {
						this.$refs.mescrollItem1.getrecords()
					} else {
						uni.navigateTo({
							url: '/pages/login/index'
						});
					}
				} 
			},
		}
	}
</script>
<style lang="scss">
	.vue-ref {
		padding: 0 !important;
	}
	.word {
		&container {
			position: relative;
		}
	}
	.left {
		display: flex;
		margin: 10px;
	}
	.example-body {
		display: flex;
		padding: 10px 20px;
		background-color: #fff;
		width: 100%;
		position: fixed;
		z-index: 2;
	}
	.center {
		position: absolute;
		top: 45px;
		width: 100%;
		// height: 100%;
		border-top: 1px solid #e5e5e5;
	}
	.stateBtnSelected {
		background-color: #bbe5ff;
		color: #1480cd !important;
		border-radius: 20px;
		font-size: 14px;
		height: 25px;
		line-height: 25px;
		// width: 60px;
		margin: 0 5px;
		padding: 0 15px;
		text-align: center;
	}
	.stateBtnNoselect {
		background-color: transparent;
		color: #8f939c !important;
		border: none !important;
		font-size: 14px;
		height: 25px;
		line-height: 25px;
		// width: 60px;
		margin: 0 5px;
		padding: 0 15px;
		text-align: center;
	}
	.slot-image {
		width: 30px;
		height: 30px;
	}
	.slot-box {
		margin-right: 10px;
	}
	.uni-list-item__container {
		align-items: center !important;
		line-height: 20px;
	}
</style>

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/405712.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

【Node.js实战】一文带你开发博客项目之登录(前置知识)

个人简介 &#x1f440;个人主页&#xff1a; 前端杂货铺 &#x1f64b;‍♂️学习方向&#xff1a; 主攻前端方向&#xff0c;也会涉及到服务端 &#x1f4c3;个人状态&#xff1a; 在校大学生一枚&#xff0c;已拿多个前端 offer&#xff08;秋招&#xff09; &#x1f680;未…

微信小程序自定义组件(超详细)

&#x1f48c;写在开头&#xff1a; 哈喽呀&#xff0c;亲爱的宝子们。 今天要介绍的是关于小程序自定义组件的相关内容。 主要分以下几个部分&#xff1a;组件的创建&#xff0c;组件的结构&#xff0c;组件的引用&#xff0c;组件样式&#xff0c;组件的生命周期等。 文章目录…

【蓝桥杯真题】当蓝桥杯开设Web组之后,对几题能拿省一?

目录 &#x1f3c6;难度分析 &#x1f3c6;一、水果拼盘 &#x1f3c6;二、展开你的扇子 &#x1f3c6;三、和手机相处的时光 &#x1f3c6;四、灯的颜色变化 &#x1f3c6;五、冬奥大抽奖 &#x1f3c6;六、蓝桥知识网 &#x1f3c6;七、布局切换 &#x1f3c6;八、购…

vue3,使用watch监听props中的数据

情况一&#xff1a;监听 props 中基本数据类型 父组件中对传入数据的处理 const handleClick () > {testStr.value P }子组件中监听传入的数据 watch(() > props.testStr,(newVal, oldVal) > {console.log(监听基本类型数据testStr)console.log(new, newVal)cons…

Vue 和 React 有什么不同?

大家好&#xff0c;我是前端西瓜哥。今天的文章简单探讨一下 Vue 和 React 的不同。 本人 Vue2 和 React 都用过&#xff0c;但不熟悉 Vue3&#xff0c;没用它做过项目。 其实我对这两大框架也没有认真钻研过它们的细节&#xff0c;也就是工作上用它们写一些简单业务&#xf…

解决npm ERR! Cannot read properties of null (reading ‘pickAlgorithm‘)报错问题

在vue项目中&#xff0c;使用npm i 命令安装node modules时&#xff0c;出现报错。 第一句&#xff1a; npm ERR! Cannot read properties of null (reading pickAlgorithm) 搜索的话也是有很多答案的&#xff0c;比如&#xff1a; 在终端中运行命令&#xff1a;npm cache cle…

Vue使用axios进行get请求拼接参数的几种方式

前言 本文主要介绍如何在Vue使用axios进行get请求拼接参数的两种方式 我们就以github上的一个开源接口举例&#xff1a; https://api.github.com/search/users?qxxx 这是github给开发人员提供的一个接口&#xff0c;是get请求。我们可以直接通过浏览器访问 很明显&#xff0…

ECharts 饼图颜色设置教程 - 4 种方式设置饼图颜色

本文首发&#xff1a;《ECharts 饼状图颜色设置教程 - 4 种方式设置饼图颜色》 ECharts 饼状图颜色设置教程 方法一&#xff1a;在 series 内配置饼状图颜色方法二&#xff1a;在 option 内配置饼状图颜色方法三&#xff1a;在 data 内配置饼状图颜色方法四&#xff1a;配置 E…

UE4 利用WEBUI插件完成UE与JS的交互 (UE4嵌入WEB)

目录 一、UE4显示Echart图表 二、UE调用JS&#xff08;修改Echart图表数据&#xff09; 三、JS调用UE&#xff08;UE4中打印js传递过来的数据&#xff09; 一、UE4显示Echart图表 步骤&#xff1a; 1.下载WEBUI插件 我的UE编辑器版本是4.24.3对应版本的插件下载地址是 链…

全站最简单 “数据滚动可视化大屏” 【JS基础拿来即用】

源码获取方式&#xff1a; 数据滚动大屏源码&#xff0c;原生js实现超级简单-Javascript文档类资源-CSDN下载原生js实现的数据滚动大屏案例&#xff0c;实现应该是全网最简单的&#xff0c;拿来直接使用即可&#xff0c;没有会员的小伙伴去我文章主更多下载资源、学习资料请访问…

聊一聊浏览器打印 - window.print

前言 一般信息填写类的需求页面&#xff0c;都会增设「预览」和「打印」功能。我们会通过编写 DOM 及样式来绘制出预览视图&#xff0c;而打印则是基于预览来生成 PDF 文件。 浏览器原生 API window.print() 可以用于打印当前窗口&#xff08;window.document&#xff09;视图…

CSS中animation动画-详解

1、animation有什么组成&#xff1f; Animations由两部分组成&#xff1a;css动画的配置&#xff0c;以及一系列的keyframes&#xff08;用来描述动画的开始、过程、结束状态&#xff09;。不需要了解任何Js技术即可完成动画的制作 2、关键帧应该怎么表示&#xff1f; 0%表示…

CSS的hover属性

1.hover的定义 :hover在鼠标移到链接上时添加的特殊样式 :hover适用于任何元素 2.hover的使用方法 用法1:控制自身的样式 鼠标悬浮在元素上改变元素样式,改变本身的背景颜色,例如: 用法2&#xff1a;通过hover控制其他块的样式 &#xff08;1&#xff09;控制子元素的样式…

【React Router 6 快速上手二】useParams / useSearchParams / useLocation / 编程式路由导航useNavigate等API

前言 博主主页&#x1f449;&#x1f3fb;蜡笔雏田学代码 专栏链接&#x1f449;&#x1f3fb;React专栏 之前学习了react-router-dom5版本的相关内容 参考文章&#x1f449;&#x1f3fb;React路由组件传参的三种方式和 【React路由】编程式路由导航 回顾上篇文章&#x1f449…

nvm管理node版本

nvm 使用 1. nvm介绍 nvm 全英文也叫 node.js version management&#xff0c;是一个 nodejs 的版本管理工具 nvm 和 npm 都是 node.js 版本管理工具&#xff0c;为了解决 node.js 各种版本存在不兼容现象可以通过它可以安装和切换不同版本的 node.js 2. 安装与配置 2-1 nv…

CSS绝对定位(absolute)、相对定位(relative)方法(详解)

CSS中几种常用的定位方法&#xff0c;直接上干货&#xff01; 什么是定位&#xff1f; 元素可以使用的顶部&#xff0c;底部&#xff0c;左侧和右侧属性定位。然而&#xff0c;这些属性无法工作&#xff0c;除非是先设定 position属性。他们也有不同的工作方式&#xff0c;这…

Echarts直角坐标系x轴y轴属性设置大全

1、Echarts版本 "echarts": "^5.3.3", 2、最简单的直角坐标系&#xff0c;以柱状图为例。 常见的直角坐标系&#xff0c;x轴设置type: category&#xff0c;为类目轴&#xff0c;适用于离散的类目数据&#xff1b;y轴设置type: value&#xff0c;为数值轴…

前端编程中你是如何进行调试代码的?这篇文章让你学会更多调试方法——前端新手进阶

要我讲就是&#xff1a;对自己代码自信的人&#xff0c;从来不需要调试&#xff0c;只是log一下值是否符合预期(doge)。 哈哈&#xff0c;这当然是一句玩笑话&#xff0c;不管你是刚刚起步的新手&#xff0c;还是从业多年的老手&#xff0c;编程中或多或少都会遇到一些瓶颈&…

Vue3中的watch监听

目录 一、监听基础ref类型 1、监听单个ref数据 2、 监听多个ref数据 二、监听reactive类型 1、监听对象中单个属性 2、监听对象中多个属性 3、同时监听ref基本类型数据和reactive对象中的属性 4、监听整个对象 5、监听对象中值为对象的属性 三、watchEffect 一、监听基础…

JS数组方法中哪些会改变原数组,哪些不会?

前言 作为一名前端开发人员&#xff0c;我们每天都会与数组打交道。JS 也提供了很多操作数组的原生 API 供我们调用。在这些方法里面&#xff0c;有的方法会改变原数组&#xff0c;有些不会改变原数组。别看这一点小小的区别&#xff0c;往往会造成巨大的影响&#xff0c;特别…