复制代码<template>
<!-- 区域选择 -->
<uni-data-picker :clear-icon="false" placeholder="区域" popup-title="请选择所在地区" :localdata="addressTree" v-model="condition.address" :map="{text:'name', value: 'id'}" />
</template>
<script lang="ts" setup>
import { reactive, ref } from 'vue';
import { getRegionUrl } from '../../api/fast-rental-api';
import { onShow } from '@dcloudio/uni-app';
import api_request from '../../libs/request.js';
const condition = reactive({ address: ""});
const addressTree = ref < any[] > ([]);
const getRegion = () => {
uni.showLoading({ title: 'loading...' });
const { promise } = api_request.request(getRegionUrl, 'GET');
promise
.then((res: any) => {
const a = [{ id: '0', name: '不限' }, ...res];
addressTree.value.length = 0;
addressTree.value.push(...a);
})
.catch((err: any) => {
const { message, errMsg, error } = err;
uni.showToast({ icon: 'none', title: message || errMsg || error, duration: 3000 });
console.error(err);
})
.finally(() => {
uni.hideLoading();
});
};
onShow(() => {
getRegion();
});
</script>
<style lang="scss" scoped></style>

- 发布:2023-02-13 23:00
- 更新:2023-10-10 22:50
- 阅读:1432
产品分类: uniapp/小程序/微信
PC开发环境操作系统: Mac
PC开发环境操作系统版本号: mac pro m1 ventura 13.2
HBuilderX类型: 正式
HBuilderX版本号: 3.6.18
第三方开发者工具版本号: 1.06.2301160 darwin-arm64
基础库版本号: 2.27.3
项目创建方式: HBuilderX
示例代码:
操作步骤:
直接运行
直接运行
预期结果:
picker的数据能动态变化
picker的数据能动态变化
实际结果:
只接受初始化的值
只接受初始化的值
bug描述:
uni-data-picker组件动态修改localdata无效
2 个回复
YUANRJ
感谢反馈,已修复 更新下插件 https://ext.dcloud.net.cn/plugin?name=uni-data-picker
m***@163.com
用的是uni-starter的模板,搞了我几天,也没有人回答。。。。。。
一直以为我自己不对,原来更新一下就行了,这坑啊。