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>
相关推荐
乘风gg1 小时前
为什么AI 时代来临,大部分人吃不到红利
前端·ai编程·claude
恋猫de小郭2 小时前
Android 限制侧载新进展,谷歌联合国内厂商推验证计划
android·前端·flutter
IT_陈寒2 小时前
Redis内存爆了,原来我漏掉了这个致命配置
前端·人工智能·后端
恋猫de小郭2 小时前
解读 Android 17 全新内存限制,有没有“豁免”后门?
android·前端·flutter
Hyyy3 小时前
理解LLM的基本工作原理:预训练、微调、推理的区别
前端
Gatlin4 小时前
前端逆向与反逆向:一场猫鼠游戏的底层逻辑与实战
前端
Pedantic4 小时前
本地通知(Local Notifications)学习笔记
前端
森蓝情丶4 小时前
我给 AI 搭了个法庭:一个前端仔的 LangGraph 实战全记录
前端·后端
爱勇宝5 小时前
干了近 8 年,一夜之间被裁:AI 时代,程序员最该害怕的不是 AI
前端·后端·程序员
Pedantic5 小时前
Combine 框架学习笔记
前端