uniapp常用组件
时间: 2024-07-24 14:01:43 浏览: 89
UniApp是一款基于Vue.js的跨平台应用开发框架,它提供了一套统一的API和组件库,支持快速构建原生体验的应用。常用的UniApp组件包括:
1. **页面容器**: `view` - 最基本的布局元素,用于显示内容。
2. **导航栏`: `navigator` - 提供顶部导航,常见的有底部导航栏(tabbar)和侧滑菜单。
3. **列表组件**: `list` 和 `cell` - 用于展示一系列有序或无序的数据项。
4. **卡片组件**: `picker`, `carousel` - 展示信息的模块,如选项选择、图片轮播等。
5. **表单组件**: `input`, `checkbox`, `radio`, `picker`, `datePicker`, `timePicker` - 用于收集用户输入的各种控件。
6. **弹窗组件**: `dialog`, `alert`, `confirm` - 显示提示信息、确认对话框等。
7. **加载状态**: `loading` - 显示数据加载过程的动画效果。
8. **路由管理**: `router-view` 和 `router-link` - 实现页面间的跳转和链接。
此外,还有各类UI元素和交互组件,如按钮(`button`), 分隔线(`divider`), 图片(`image`), 标签页(`tab`)等。开发者可以根据需求组合这些组件来创建丰富的用户界面。使用UniApp的组件化开发模式,可以显著提升开发效率,并且由于其跨平台特性,应用可以在iOS、Android、Web等多个平台上运行。
相关问题
学习了uniapp常用组件,常用API,自定义组件,写一份日报
日报内容:今天我学习了uniapp常用组件、常用API和自定义组件,学习了如何使用这些组件来制作一个简单的应用程序。学习了如何使用API来获取数据。学习了如何创建自定义组件,以满足特定的需求。通过今天的学习,我对uniapp有了更加深入的了解,能够更好地应用到实际项目中。
uniapp常用 ui组件
### UniApp 常用 UI 组件列表及使用方法
#### 1. 图标组件 `uni-icons`
`uni-icons` 是用于显示图标的组件,支持多种内置图标样式。通过设置属性 `type` 来指定不同的图标类型。
```html
<template>
<view>
<uni-icons type="home" size="30"></uni-icons>
</view>
</template>
<script>
export default {
}
</script>
```
此代码片段展示了如何创建一个大小为30px的家庭图标[^2]。
#### 2. 宫格组件 `uni-grid`
该组件适用于展示多个项目的网格布局,可通过配置项调整列数和其他外观特性。
```html
<template>
<view>
<uni-grid :column="3">
<uni-grid-item v-for="(item, index) in items" :key="index">
<!-- Grid item content -->
</uni-grid-item>
</uni-grid>
</view>
</template>
<script>
export default {
data() {
return {
items: ['Item 1', 'Item 2', 'Item 3']
}
}
}
</script>
```
这段脚本实现了三列的宫格式排列,并循环渲染数据集合中的每一项。
#### 3. 卡片组件 `uni-card`
卡片是一种常见的信息容器,能够承载文字、图片等内容。可以通过简单的标签嵌套实现复杂的内容结构。
```html
<template>
<view>
<uni-card title="Card Title">
Card Content...
</uni-card>
</view>
</template>
```
上述例子说明了怎样快速搭建一张带有标题和正文内容的基础卡片。
#### 4. 导航条组件 `uni-nav-bar`
作为页面顶部的重要组成部分之一,导航栏通常用来放置应用名称或返回按钮等功能性元素。
```html
<template>
<view>
<uni-nav-bar left-icon="back" @click-left="goBack">Page Title</uni-nav-bar>
</view>
</template>
<script>
export default {
methods: {
goBack() {
console.log('Go back');
}
}
}
</script>
```
这里给出了一个包含左侧箭头图标并绑定点击事件处理函数的例子。
#### 5. 列表组件 `uni-list / uni-list-item`
这两个组件配合使用可轻松构建各种类型的列表视图,如联系人列表、菜单选项等。
```html
<template>
<view>
<uni-list>
<uni-list-item title="List Item 1"/>
<uni-list-item title="List Item 2"/>
</uni-list>
</view>
</template>
```
以上实例呈现了一个由两个子项构成的基本列表。
#### 6. 输入框组件 `uni-easyinput`
简化版输入控件,适合于收集用户的短文本输入,比如姓名、电话号码等基本信息。
```html
<template>
<view>
<uni-easyinput placeholder="Enter your name here..."></uni-easyinput>
</view>
</template>
```
这个模板定义了一行提示用户填写名字的地方。
#### 7. 弹窗组件 `uni-popup`
当需要向用户提供额外的信息或者请求确认操作时,可以考虑采用弹出层的形式展现给访客看。
```html
<template>
<view>
<button @click="showPopup = true">Show Popup</button>
<uni-popup ref="popup" type="center">
This is a popup message.
</uni-popup>
</view>
</template>
<script>
export default {
data() {
return { showPopup: false };
},
watch: {
showPopup(val) {
if (!val) this.$refs.popup.close();
else this.$nextTick(() => this.$refs.popup.open());
}
}
};
</script>
```
最后一部分介绍了如何触发显示隐藏状态下的中心位置居中的消息框。
阅读全文
相关推荐
![rar](https://img-home.csdnimg.cn/images/20241231044955.png)
![zip](https://img-home.csdnimg.cn/images/20241231045053.png)
![.zip](https://img-home.csdnimg.cn/images/20241231045053.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![-](https://img-home.csdnimg.cn/images/20241226111658.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)