当前位置:网站首页>【底部弹出-选择器】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~
边栏推荐
- From 20s to 500ms, I used these three methods
- Is it safe and reliable to open an account in Caixue school and make new debts?
- 下载在线视频 m3u8使用教程
- Three methods of finding inverse numbers
- Correlation - intra group correlation coefficient
- 记录一下大文件上传偶然成功偶然失败问题
- It's nothing to be utilitarian!
- Relevant settings of wechat applet cache expiration time (recommended)
- Is the securities account given by qiniu business school safe? Where can I open an account
- [Qt] résoudre le problème que Qt msvc 2017 ne peut pas Compiler
猜你喜欢

下载在线视频 m3u8使用教程

It's nothing to be utilitarian!
Linux CentOS7安装Oracle11g的超完美新手教程

Dongge cashes in and the boss retires?

Kyushu cloud and Intel jointly released the smart campus private cloud framework, enabling new infrastructure for education

SQL Server 安装指南

Leetcode skimming: stack and queue 04 (delete all adjacent duplicates in the string)

Leetcode skimming: stack and queue 02 (realizing stack with queue)

Take the enclave Park as a sample to see how Yuhua and Shaoshan play the song of Chang Zhu Tan integrated development

Learn online case practice
随机推荐
vue 强制清理浏览器缓存
Take the enclave Park as a sample to see how Yuhua and Shaoshan play the song of Chang Zhu Tan integrated development
Asp . Text of automatic reply to NETCORE wechat subscription number
GaussDB(for MySQL) :Partial Result Cache,通过缓存中间结果对算子进行加速
Use the htaccess file to prohibit the script execution permission in the directory
Barbie q! How to analyze the new game app?
Difficult to get up syndrome (bit by bit greed)
SQL数据分析之子查询的综合用法和案例题【耐心整理】
Kyushu cloud and Intel jointly released the smart campus private cloud framework, enabling new infrastructure for education
微信小程序缓存过期时间的相关设置(推荐)
UDS bootloader of s32kxxx bootloader
股票开户哪个证券公司比较安全
[template] adaptive Simpson integral
【QT】Qt 使用MSVC2017找不到编译器的解决办法
leetcode96不同的二叉搜索树
[embedded system course design] a single key controls the LED light
数据分析方法论与前人经验总结【笔记干货】
如何提升数据质量
B tree and b+tree of MySQL
Using multithreaded callable to query Oracle Database