uniapp中uview组件库丰富的tab标签

目录

[Tag 标签](#Tag 标签)

基本使用

#自定义主题

#圆形标签

#镂空标签

#镂空带背景色

#自定义尺寸

#可关闭标签

#带图片和图标

[#单选标签 和 多选标签](#单选标签 和 多选标签)


Tag 标签

tag组件一般用于标记和选择,我们提供了更加丰富的表现形式,能够较全面的涵盖您的使用场景

基本使用

  • 通过type参数设置主题类型,默认为primary

  • 属性text设置标签内容

    <u-tag text="标签" plain size="mini" type="warning"></u-tag>

#自定义主题

复制代码
<u-tag text="标签"></u-tag>
<u-tag text="标签" type="warning"></u-tag>
<u-tag text="标签"type="success"></u-tag>
<u-tag text="标签" type="error"></u-tag>

#圆形标签

  • 类似胶囊形状

    <u-tag text="标签" plain shape="circle"></u-tag>
    <u-tag text="标签" type="warning" shape="circle"></u-tag>

#镂空标签

复制代码
<u-tag text="标签" plain > </u-tag>
<u-tag text="标签" type="warning" plain></u-tag>
<u-tag text="标签" type="success" plain></u-tag>
<u-tag text="标签" type="error" plain></u-tag>

#镂空带背景色

  • 添加plainFill属性镂空带背景色

    <u-tag text="标签" plain > </u-tag>
    <u-tag text="标签" type="warning" plain plainFill></u-tag>
    <u-tag text="标签" type="success" plain plainFill></u-tag>
    <u-tag text="标签" type="error" plain plainFill></u-tag>

#自定义尺寸

  • size属性为您提供了三种规格的标签大小,默认中等。

    <u-tag text="标签" plain size="mini"></u-tag>
    <u-tag text="标签" type="warning"></u-tag>
    <u-tag text="标签" type="success" plain size="large"></u-tag>

#可关闭标签

  • tag在右上角提供了删除标签的样式

    <u-tag text="标签" size="mini" closable :show="close1" @close="close1 = false"></u-tag>
    <u-tag text="标签" type="warning" closable :show="close2" @close="close2 = false"></u-tag>
    <u-tag text="标签" type="success" plain size="large"
    closable :show="close3" @close="close3 = false"></u-tag>

    <script> export default { data() { return { close1: true, close2: true, close3: true, radios: [{ checked: true }, { checked: false }, { checked: false } ], checkboxs: [{ checked: true }, { checked: false }, { checked: false } ] } }, } </script>

#带图片和图标

复制代码
<u-tag text="标签" size="mini" icon="map" plain></u-tag>
<u-tag text="标签" type="warning" icon="tags-fill"></u-tag>
<u-tag text="标签" type="success" plain size="large"
icon="https://cdn.uviewui.com/uview/example/tag.png"></u-tag>

#单选标签 和 多选标签

  • 我们为您提供了单选和多选的事件,您可以在事件中获取参数列表

    <template> <view class="u-page__tag-item" v-for="(item, index) in radios" :key="index"> <u-tag :text="`选项${index + 1}`" :plain="!item.checked" type="warning" :name="index" @click="radioClick"> </u-tag> </view> <view class="u-page__tag-item" v-for="(item, index) in checkboxs" :key="index"> <u-tag :text="`选项${index + 1}`" :plain="!item.checked" type="warning" :name="index" @click="checkboxClick"> </u-tag> </view> </template> <script> export default { data() { return { radios: [{ checked: true }, { checked: false }, { checked: false } ], checkboxs: [{ checked: true }, { checked: false }, { checked: false } ] } }, methods: { radioClick(name) { this.radios.map((item, index) => { item.checked = index === name ? true : false }) }, checkboxClick(name) { this.checkboxs[name].checked = !this.checkboxs[name].checked } } } </script> <style lang="scss"> .u-page__tag-item { margin-right: 20px; } </style>
相关推荐
奶糖 肥晨1 小时前
解决 UniApp 自定义弹框被图片或 Canvas 覆盖的 Bug
uni-app·bug
荷花微笑1 小时前
HBuilderX升级,Vue2 scss 预编译器默认已由 node-sass 更换为 dart-sass
uni-app·css3
2501_916007477 小时前
iOS App 上架实战 从内测到应用商店发布的全周期流程解析
android·ios·小程序·https·uni-app·iphone·webview
anyup9 小时前
🔥 🔥 为什么我建议你使用 uView Pro 来开发 uni-app 项目?
前端·vue.js·uni-app
小小怪下士_---_12 小时前
uniapp开发微信小程序自定义导航栏
前端·vue.js·微信小程序·小程序·uni-app
anyup15 小时前
🔥🔥 uView Pro:Vue3+TS重构的uni-app开源组件库,文档免费无广告!
前端·vue.js·uni-app
样子20181 天前
Uniapp 之renderjs解决swiper+多个video卡顿问题
前端·javascript·css·uni-app·html
fakaifa1 天前
点大餐饮独立版系统源码v1.0.3+uniapp前端+搭建教程
小程序·uni-app·php·源码下载·点大餐饮·扫码点单
Bug改不动了1 天前
React Native 与 UniApp 对比
react native·react.js·uni-app
anyup1 天前
🔥🔥 10 天 Star 破百!uView Pro 文档也开源啦:完全免费、无广告、高效上手
前端·vue.js·uni-app