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

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>
http://www.xdnf.cn/news/13206.html

相关文章:

  • Linux中shell流程控制语句
  • 【为什么RabbitMQ能够控制事务?控制事务的原理】
  • DAY 49 CBAM注意力
  • C++ 类基础:封装、继承、多态与多线程模板实现
  • Python开发基础手语识别(基础框架版)
  • Ansible 错误处理:确保高效自动化
  • 【工具】Configurable-HTTP-Proxy 使用指南
  • 倒装芯片凸点成型工艺
  • TSN交换机正在重构工业网络,PROFINET和EtherCAT会被取代吗?
  • 相关类相关的可视化图像总结
  • Polarr:手机修图,专业与创意并存
  • 数据库管理与高可用-MySQL故障排查与生产环境优化
  • 一种新的编程语言,这种新编程语言叫做『人类语言』
  • 基于大模型预测原发性急性闭角型青光眼的技术方案研究大纲
  • Django RBAC项目后端实战 - 03 DRF权限控制实现
  • 无菌药厂通信架构升级:MODBUS TCP转CANopen技术的精准控制应用
  • 云原生时代的系统设计:架构转型的战略支点
  • Electron简介(附电子书学习资料)
  • 什么是日内融?日内融交易系统开发全解析
  • 第三方检测:软件渗透测试
  • 视觉slam--框架
  • 如何将联系人从 iPhone 转移到 Android
  • linux中如何在日志里面检索nowStage不等于1的数据的指令
  • 视频行为标注工具BehaviLabel(源码+使用介绍+Windows.Exe版本)
  • Java解析前端传来的Unix时间戳
  • Vue 自动导入函数和变量插件 unplugin-auto-import
  • MySQL故障排查、生产环境优化与存储引擎MyISAM和InnoDB
  • 什么是TRS收益互换?金融创新架构下的交易系统开发与实践
  • MacBook pro 修改Homebrew 为中国源
  • [Java恶补day20] 54. 螺旋矩阵