当前位置:网站首页>【底部弹出-选择器】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~
边栏推荐
- 创业团队如何落地敏捷测试,提升质量效能?丨声网开发者创业讲堂 Vol.03
- Three methods of finding inverse numbers
- 【CTF】bjdctf_2020_babystack2
- LeetCode 0241.为运算表达式设计优先级 - DFS
- Leetcode skimming: stack and queue 01 (realizing queue with stack)
- 【QT】QtCreator卸载与安装(非正常状态)
- B tree and b+tree of MySQL
- Qt5.12.9 migration tutorial based on Quanzhi H3
- 使用 ES 实现疫情地图或者外卖点餐功能(含代码及数据)
- 【QT】對於Qt MSVC 2017無法編譯的問題解决
猜你喜欢

leetcode96不同的二叉搜索樹

SQL数据分析之子查询的综合用法和案例题【耐心整理】

Leetcode skimming: binary tree 03 (post order traversal of binary tree)

Niuke - Practice 101 - reasoning clown

JS -- image to base code, base to file object

What does open loop and closed loop mean?

Kuberntes cloud native combat high availability deployment architecture

Asp .NetCore 微信订阅号自动回复之文本篇
![[QT] QT cannot find a solution to the compiler using msvc2017](/img/80/a4b17d6cc1ab6fe1366a3a3f43ec2e.png)
[QT] QT cannot find a solution to the compiler using msvc2017

使用多线程Callable查询oracle数据库
随机推荐
Download the online video m3u8 tutorial
Export default the exported object cannot be deconstructed, and module Differences between exports
Node——Egg 创建本地文件访问接口
Mysql database driver (JDBC Driver) jar package download
Guide d'installation du serveur SQL
股票开户哪个证券公司比较安全
在证券账户上买基金安全吗?哪里可以买基金
Leetcode skimming: stack and queue 01 (realizing queue with stack)
Using multithreaded callable to query Oracle Database
Record the accidental success and failure of uploading large files
Operate database transactions with jpatractionmanager
How can entrepreneurial teams implement agile testing to improve quality and efficiency? Voice network developer entrepreneurship lecture Vol.03
【opencv】train&test HOG+SVM
Leetcode medium question sharing (5)
[QT] test whether QT can connect to the database
Comprehensive usage and case questions of sub query of SQL data analysis [patient sorting]
Dongge cashes in and the boss retires?
实例讲解将Graph Explorer搬上JupyterLab
Windows10 install WSL (I) (wslregisterdistribution error)
Qt5.12.9 migration tutorial based on Quanzhi H3