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>
相关推荐
00后程序员张10 小时前
对比 Ipa Guard 与 Swift Shield 在 iOS 应用安全处理中的使用差异
android·开发语言·ios·小程序·uni-app·iphone·swift
00后程序员张14 小时前
在 iOS 设备上同时监控 CPU、GPU 与内存的方法
android·ios·小程序·https·uni-app·iphone·webview
游戏开发爱好者818 小时前
在 Windows、Linux 与 CI 环境下命令行上传 IPA 到 App Store
linux·windows·ios·ci/cd·小程序·uni-app·iphone
码农客栈20 小时前
小程序学习(十三)之请求和上传文件拦截器
小程序·uni-app
龙井>_<20 小时前
uniapp“手搓”一个年月选择器模态框(兼容多端)
uni-app
web_Hsir20 小时前
uniapp + vue2 + pfdjs + web-view 实现安卓、iOS App PDF预览
android·前端·uni-app
peachSoda721 小时前
uniapp app使用命令行HBuilderX cli快捷打包iOS和Android
uni-app
2501_916007472 天前
跨平台 App 安全,Flutter、RN、Unity、H5 混合应用加固
android·ios·小程序·https·uni-app·iphone·webview
咕咕咕_biubiubiu2 天前
uniapp插件——原生插件开发和使用
uni-app
芋头莎莎2 天前
UNIAPP连接MQTT记录要点
uni-app