当前位置:网站首页>【底部弹出-选择器】uniapp Picker组件——底部弹起的滚动选择器
【底部弹出-选择器】uniapp Picker组件——底部弹起的滚动选择器
2022-07-02 00:28:00 【马小跳的Coding进阶之路】
一、要实现的效果,如下图所示:


二、代码:
<template>
<view>
//mode : selector是最普通的选择器,[具体可参考文档。](https://uniapp.dcloud.io/component/picker.html)
//range :想绑定的数组。
//range-key :想在弹出框中显示数组的哪个key值。比如我想显示数组中color title的值,就不能写成id。
//@change :点击选择时会触发这个回调函数。
<picker @change="colorChange" :value="colorIndex" :range="colorList" range-key="title">
<view class="uni-input">{
{colorList[colorIndex].title}}</view>
</picker>
</view>
</template>
<script> export default {
data() {
return {
//选中的颜色下标 colorIndex:0, //在picker列表所选中项的颜色id color_id: '', //颜色列表数据(假数据,可以在接口函数里面发请求获取真实的后台数据) colorList:[ {
id: 1, title: '红色'}, {
id: 2, title: '绿色'}, {
id: 3, title: '蓝色'} ], } }, onLoad() {
this.getCaseList() }, methods: {
// 颜色筛选 colorChange(e){
this.colorIndex = e.detail.value this.getCaseList() }, //案例列表-接口 getCaseList() {
var that = this; that.page = 1; var params = {
//颜色id color_id: that.colorList.length>0? that.colorList[that.colorIndex].id:'', page: that.page, limit: that.limit } this.$api.appPlateForm('POST', 'example/index', params, function(res) {
if (res.code == 200) {
that.colorList = res.data.color //颜色 that.colorList.unshift({
id:'',title:'颜色'}); if(res.data.data.length>0){
that.caselist = res.data.data; that.page++ }else{
that.caselist =[]; } that.$forceUpdate(); } }, function(err) {
uni.showToast({
icon: 'none', title: err.msg }) }); }, }, } </script>
ending~
边栏推荐
- Data analysis methodology and previous experience summary [notes dry goods]
- PHP reads ini or env type configuration
- SQL Server Installation Guide
- 2023款雷克萨斯ES产品公布,这回进步很有感
- Leetcode 96 différents arbres de recherche binaires
- leetcode96不同的二叉搜索树
- 下载在线视频 m3u8使用教程
- Jielizhi, production line assembly link [chapter]
- USB-IF协会与各种接口的由来
- UDS bootloader of s32kxxx bootloader
猜你喜欢
![Data analysis methodology and previous experience summary [notes dry goods]](/img/00/e4c4cf37f1ca9134546f970d800226.png)
Data analysis methodology and previous experience summary [notes dry goods]

Export default the exported object cannot be deconstructed, and module Differences between exports
![[QT] test whether QT can connect to the database](/img/63/32530c15995ef23bde8cadc3adfd11.png)
[QT] test whether QT can connect to the database

Qt5.12.9 migration tutorial based on Quanzhi H3

回顾数据脱敏系统

起床困难综合症(按位贪心)
![[QT] solve the problem that QT MSVC 2017 cannot compile](/img/35/e458fd437a0bed4bace2d6d65c9ec8.png)
[QT] solve the problem that QT MSVC 2017 cannot compile

Leetcode 96 différents arbres de recherche binaires

Using multithreaded callable to query Oracle Database
![Jielizhi, production line assembly link [chapter]](/img/1d/d1736fad33c428e61f450aad512ce0.png)
Jielizhi, production line assembly link [chapter]
随机推荐
Operate database transactions with jpatractionmanager
Windows installation WSL (II)
Use the htaccess file to prohibit the script execution permission in the directory
EMC circuit protection device for surge and impulse current protection
Jielizhi, production line assembly link [chapter]
二叉搜索树的创建,查找,添加,删除操作
Material design component - use bottomsheet to show extended content (I)
UDS bootloader of s32kxxx bootloader
The new version of graphic network PDF will be released soon
启牛商学院给的证券账户安不安全?哪里可以开户
An intern's journey to cnosdb
Data analysis methodology and previous experience summary [notes dry goods]
What is ThreadLocal memory leak and how to solve it
BPR (Bayesian personalized sorting)
Ldr6035 smart Bluetooth audio can continuously charge and discharge mobile devices
Node - generate wechat permission verification configuration
基于全志H3的QT5.12.9移植教程
Difficult to get up syndrome (bit by bit greed)
Selectively inhibiting learning bias for active sampling
Which securities company is safer to open a stock account