type 属性的用途和实现方式(图标,表单,数据可视化,自定义组件)

1.图标类型

<uni-icon>组件中,type可以用来指定图标的不同样式。

复制代码
<uni-icons type="circle" size="30" color="#007aff"></uni-icons>     //表示圆形
<uni-icons type="square" size="30" color="#007aff"></uni-icons>    //表示方形
<uni-icons type="triangle" size="30" color="#007aff"></uni-icons>    //表示三角形
<uni-icons class="input-uni-icon" type="search" size="1" color="#999" />    //表示搜索图形

2.表单控件类型

在表单元素中,type属性用于指定输入控件的类型。

复制代码
<input type="text" placeholder="文本输入框">
<input type="password" placeholder="密码输入框">
<input type="checkbox"> 复选框
<input type="radio"> 单选框
<input type="file"> 文件选择

3.数据可视化图标类型

在数据可视化库中,type属性用于指定图表的类型

复制代码
// 使用 Plotly 创建柱状图
Plotly.newPlot('myDiv', [{
  x: [1, 2, 3, 4],
  y: [10, 15, 13, 17],
  type: 'bar'  // 柱状图
}]);

// 使用 Plotly 创建饼图
Plotly.newPlot('myDiv', [{
  labels: ['A', 'B', 'C'],
  values: [10, 20, 30],
  type: 'pie'  // 饼图
}]);

4.自定义组件中的类型

复制代码
<my-component type="primary">主要按钮</my-component>
<my-component type="secondary">次要按钮</my-component>
<my-component type="danger">危险按钮</my-component>
相关推荐
web小白成长日记3 小时前
企业级 Vue3 + Element Plus 主题定制架构:从“能用”到“好用”的进阶之路
前端·架构
APIshop4 小时前
Python 爬虫获取 item_get_web —— 淘宝商品 SKU、详情图、券后价全流程解析
前端·爬虫·python
风送雨4 小时前
FastMCP 2.0 服务端开发教学文档(下)
服务器·前端·网络·人工智能·python·ai
XTTX1104 小时前
Vue3+Cesium教程(36)--动态设置降雨效果
前端·javascript·vue.js
LYFlied5 小时前
WebGPU与浏览器边缘智能:开启去中心化AI新纪元
前端·人工智能·大模型·去中心化·区块链
Setsuna_F_Seiei5 小时前
2025 年度总结:人生重要阶段的一年
前端·程序员·年终总结
model20055 小时前
alibaba linux3 系统盘网站迁移数据盘
java·服务器·前端
han_6 小时前
从一道前端面试题,谈 JS 对象存储特点和运算符执行顺序
前端·javascript·面试
aPurpleBerry6 小时前
React 01 目录结构、tsx 语法
前端·react.js
jayaccc6 小时前
微前端架构实战全解析
前端·架构