uniapp多端插件:Tabs标签页 灵活配置 多端兼容 简单易用(与element-ui的Tabs 标签页使用一致)

概要

在做项目的过程中用到了tab切换,本想着去插件市场找一个直接现用,后面发现找到的tab切换并不是我想要的那种使用方式,于是我结合了element-ui中Tabs标签页的方式写了该组件。

Tips
  1. 该插件使用的预编译,需要自行安装scss/sass插件。
  2. 该插件同时兼容了VUE2和VUE3,hbuilderX 最好是更新到较新版本。
  3. 由于组件重构升级,老用户需要更新插件的,需要注意参数,根据下面提供的参数修改即可。
  4. 遵循uni_modules规范插件。
  5. 如果发现组件有bug或者不完善可以留言交流。
  6. uniapp插件git地址:https://gitee.com/my_dear_li_pan/my-uni-modules.git
  7. 个人博客地址:https://blog.csdn.net/qq_42961150?spm=1011.2124.3001.5343
支持的平台
  • H5、app-vue、微信小程序、百度小程序等小程序平台。
  • 暂不支持nvue。
  • cli脚手架项目是否可用,暂未测试。
使用示例
<template>
	<view>
		<custom-tabs :value="value" @change="changeIndex">
			<custom-tab-pane label="标签一" name="1">
				<view style="height: 100px;">内容0</view>
				<view style="height: 100px;">内容1</view>
				<view style="height: 100px;">内容1</view>
				<view style="height: 100px;">内容1</view>
				<view style="height: 100px;">内容1</view>
				<view style="height: 100px;">内容1</view>
				<view style="height: 100px;">内容1</view>
				<view style="height: 100px;">内容1</view>
				<view style="height: 100px;">内容1</view>
				<view style="height: 100px;">内容1</view>
			</custom-tab-pane>
			<custom-tab-pane label="标签二" name="2">内容2</custom-tab-pane>
			<custom-tab-pane label="标签三3" name="3">内容3</custom-tab-pane>
			<custom-tab-pane label="标签四44" name="4">内容4</custom-tab-pane>
			<custom-tab-pane label="标签五555" name="5">内容5</custom-tab-pane>
			<custom-tab-pane label="标签六6666" name="6">内容6</custom-tab-pane>
			<custom-tab-pane label="标签七77777" name="7">内容7</custom-tab-pane>
		</custom-tabs>
	</view>
</template>
<script setup>
    // #ifdef VUE3
	import { reactive, ref, watch } from 'vue';
	const value = ref(2);

	function changeIndex(e) {
		console.log('选中:', e)
	}
	// #endif
</script>
<script>
	// #ifdef VUE2
	export default {
		data() {
			return {
				value: 2
			}
		},
		methods: {
			changeIndex(e) {
				console.log('选中:', e)
			}
		}
	}
	// #endif
</script>
Tabs Attributes
参数说明类型是否必填可选值默认值
value选中选项的索引,从0开始Number-0
animation切换动画Booleantrue/falsetrue
duration切换动画的动画时长,单位msNumber-200
tabSpacingtab选项的左右间距,单位rpxNumber-40
tabCentertab选项是否居中显示Booleantrue/falsefalse
fixedtab选项固定Booleantrue/falsefalse
defaultTextStyle未选中tab选项的样式Object示例::defaultTextStyle="{color:'pink'}"-
activeTextStyle选中后tab选项的样式Object示例::activeTextStyle="{color:'red','font-weight':700}"-
activeLineStyle选中后tab选项下划线的样式Object示例::activeLineStyle="{'background-color':'red',height:'6rpx'}"-
Tabs Events
事件名称说明回调参数
changetab 被选中时触发被选中的标签tab实例
Tab-pane Attributes
参数说明类型是否必填可选值默认值
label选项卡标题String--
name与选项卡绑定值 value 对应的标识符,表示选项卡别名String-该选项卡在选项卡列表中的顺序值,如第一个选项卡则为’1’

----- 别忘记点赞哟,您的肯定就是对我最大的支持 END -----

关注我,不迷路

如果任何疑问的可以在评论区留言,还可以加QQ群交流:568984539,加群备注‘地区-名字-技术类型’。

更多前端等相关知识可关注我个人博客:https://blog.csdn.net/qq_42961150?spm=1011.2124.3001.5343

个人作品展示:

uniapp+vue3.2+unicloud开发微信小程序:皮皮虎去水印

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

上网的虫不叫网虫

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值