当前位置: 首页 > news >正文

uniapp实现的具备丝滑动画的标签工具栏模板

采用 uniapp 实现, 是一款具备丝滑动画的标签工具栏模板,支持 vue2、vue3;适配 web、H5、微信小程序(其他平台小程序未测试过,可自行尝试)
代码实现简约易懂,用户可根据自身需求下载模板,并进行扩展开发

可到插件市场下载尝试: https://ext.dcloud.net.cn/plugin?id=23810

  • 示例
    请添加图片描述

请添加图片描述

props 属性

defaultValue

默认高亮选项

defaultValue: {type: String,default: "unsplash",
},

orientation

设置工具栏排列方向,提供两种选项:horizontal、vertical

orientation: {type: String,default: "horizontal",
},

options

选项数组,必须具备 label、value、icon 字段

options: {type: Object,default: () => {return [{ icon: "https://img.icons8.com/?size=100&id=56579&format=png&color=ffffff", label: "Unsplash", value: "unsplash" },{ icon: "https://img.icons8.com/?size=100&id=890&format=png&color=ffffff", label: "iphone", value: "iphone" },{ icon: "https://img.icons8.com/?size=100&id=12412&format=png&color=ffffff", label: "Browsers", value: "browsers" },{ icon: "https://img.icons8.com/?size=100&id=118504&format=png&color=ffffff", label: "Facebook", value: "facebook" },]}}

事件

@onChange

点击选项时触发,返回 options 中提供的点击的选项值,

使用示例

vue2 使用示例

<template><view style="padding: 0.4em; font-size: 1.7em; height: 60vh;"><view class="flex-center"><view class="bg-circle"><ToolbarComp style="border-radius: inherit;" orientation="vertical"></ToolbarComp></view></view><view class="flex-center" style="padding-top: 60px;"><view class="flex-center bg-circle"><ToolbarComp style="border-radius: inherit;" default-value="browsers"></ToolbarComp></view></view><view class="flex-center" style="padding-top: 60px; width: 100%;"><view style="width: 100%;" class="flex-center bg-circle"><ToolbarComp style="border-radius: inherit;" default-value="iphone" :options="toolbarOptions" @onChange="handleChange"></ToolbarComp></view></view><view class="flex-center" style="padding-top: 60px; width: 100%;"><view style="width: 100%;" class="flex-center bg-react"><ToolbarComp style="border-radius: inherit;" default-value="facebook" :options="toolbarOptions"></ToolbarComp></view></view></view>
</template><script>
import ToolbarComp from './comp/toolbarComp.vue';
export default {components: {ToolbarComp},data() {return {toolbarOptions: [{ icon: "https://img.icons8.com/?size=100&id=56579&format=png&color=ffffff", label: "Unsplash", value: "unsplash" },{ icon: "https://img.icons8.com/?size=100&id=890&format=png&color=ffffff", label: "iphone", value: "iphone" },{ icon: "https://img.icons8.com/?size=100&id=12412&format=png&color=ffffff", label: "Browsers", value: "browsers" },{ icon: "https://img.icons8.com/?size=100&id=118504&format=png&color=ffffff", label: "Facebook", value: "facebook" },{ icon: "https://img.icons8.com/?size=100&id=3529&format=png&color=ffffff", label: "Pinterest", value: "pinterest" },]}},methods: {handleChange(e) {console.log('selected:', e);}}
}
</script><style scoped>
.flex-center {display: flex;justify-content: center;align-items: center;
}
.bg-circle {background-color: hsl(0, 0%, 10%);border-radius: 1em;
}
.bg-react {background-color: hsl(0, 0%, 10%);border-radius: 0.4em;
}
</style>

vue3 使用示例

<template><view style="padding: 0.4em; font-size: 1.7em; height: 60vh;"><view class="flex-center"><view class="bg-circle"><ToolbarComp style="border-radius: inherit;" orientation="vertical"></ToolbarComp></view></view><view class="flex-center" style="padding-top: 60px;"><view class="flex-center bg-circle"><ToolbarComp style="border-radius: inherit;" default-value="browsers"></ToolbarComp></view></view><view class="flex-center" style="padding-top: 60px; width: 100%;"><view style="width: 100%;" class="flex-center bg-circle"><ToolbarComp style="border-radius: inherit;" default-value="iphone" :options="toolbarOptions" @onChange="handleChange"></ToolbarComp></view></view><view class="flex-center" style="padding-top: 60px; width: 100%;"><view style="width: 100%;" class="flex-center bg-react"><ToolbarComp style="border-radius: inherit;" default-value="facebook" :options="toolbarOptions"></ToolbarComp></view></view></view>
</template><script>
import { defineComponent, reactive } from 'vue';
import ToolbarComp from './comp/toolbarComp.vue';export default defineComponent({components: {ToolbarComp},setup() {const toolbarOptions = reactive([{ icon: "https://img.icons8.com/?size=100&id=56579&format=png&color=ffffff", label: "Unsplash", value: "unsplash" },{ icon: "https://img.icons8.com/?size=100&id=890&format=png&color=ffffff", label: "iphone", value: "iphone" },{ icon: "https://img.icons8.com/?size=100&id=12412&format=png&color=ffffff", label: "Browsers", value: "browsers" },{ icon: "https://img.icons8.com/?size=100&id=118504&format=png&color=ffffff", label: "Facebook", value: "facebook" },{ icon: "https://img.icons8.com/?size=100&id=3529&format=png&color=ffffff", label: "Pinterest", value: "pinterest" },]);const handleChange = (e) => {console.log('selected:', e);};return {toolbarOptions,handleChange};}
});
</script><style scoped>
.flex-center {display: flex;justify-content: center;align-items: center;
}
.bg-circle {background-color: hsl(0, 0%, 10%);border-radius: 1em;
}
.bg-react {background-color: hsl(0, 0%, 10%);border-radius: 0.4em;
}
</style>

相关文章:

  • Django 5 学习笔记总纲
  • [蓝桥杯 2024 国 Java B] 美丽区间
  • Unity中的Mathf.Lerp
  • 记录一次opengl显示不出物体的错误原因
  • SQL进阶之旅 Day 22:批处理与游标优化
  • 什么是闭包,JavaScript闭包详解
  • 47 通道注意力 热力图
  • 基于Java项目的Karate API测试
  • SpringBoot配置
  • 245. 2019年蓝桥杯国赛 - 数正方形(困难)- 递推
  • Redis实战-黑马点评项目完结(p78-p95)
  • 曼昆《经济学原理》第九版 第十二章税收制度的设计
  • MQTT示例体验(C)
  • PyCharm 和 Anaconda 搭建Python环境【图文教程】
  • JAVA开发工具箱
  • 【ubuntu24.04】普通用户如何操作samba挂载的文件夹
  • 曼昆《经济学原理》第九版 第十章外部性
  • LangGraph 应用实例解析
  • Mysql故障排插与环境优化
  • 河北对口计算机高考MySQL笔记(完结版)(2026高考)持续更新~~~~
  • 网站要背代码?/百度登录
  • 企业网站备案要求/贵州seo和网络推广
  • 网站建设怎么样/成都搜索优化整站优化
  • 快速建手机网站/超级外链工具源码
  • 网站的用户体验/百度推广按点击收费
  • 做招聘网站怎么样/品牌策划