Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

【bug】uni-data-picker组件在readonly属性为true时选项匹配错误 #988

Open
cucuzi opened this issue Jan 27, 2025 · 5 comments
Open
Assignees

Comments

@cucuzi
Copy link

cucuzi commented Jan 27, 2025

版本信息

HbuilderX 4.45
uni-ui 1.5.7
vue3

代码片段

<template>
  <view>
    <uni-data-picker v-model="temperature" readonly placeholder="请选择最高气温"
      :localdata="temperaturePicker"></uni-data-picker>
  </view>
</template>

<script>
  export default {
    data() {
      return {
        temperature: "25",
        temperaturePicker: []
      }
    },
    onLoad() {
      for (var i = 50; i > -41; i--) {
        this.temperaturePicker.push({
          text: `${i}℃`,
          value: `${i}`
        });
      }
    }
  }
</script>

实际结果

Image

预期结果

文本框中应该是25℃

@GRCmade
Copy link
Contributor

GRCmade commented Mar 4, 2025

hello , 我尝试运行你的代码,并不能复现这个情况,您可以晚上一下代码吗?

@GRCmade GRCmade self-assigned this Mar 4, 2025
@cucuzi
Copy link
Author

cucuzi commented Mar 4, 2025

hello , 我尝试运行你的代码,并不能复现这个情况,您可以晚上一下代码吗?

抱歉,之前代码给的有误,我已修改。
示例项目代码实际上就是新建一个uni-ui项目,然后修改index.vue
录了个操作视频

QQ202534-222552.mp4

@GRCmade
Copy link
Contributor

GRCmade commented Mar 5, 2025

hello , 我尝试运行你的代码,并不能复现这个情况,您可以晚上一下代码吗?

抱歉,之前代码给的有误,我已修改。 示例项目代码实际上就是新建一个uni-ui项目,然后修改index.vue 录了个操作视频

QQ202534-222552.mp4

好的,感谢您的反馈,能够复现这个问题,我尝试看一下是什么导致的。

@cucuzi
Copy link
Author

cucuzi commented Mar 5, 2025

hello , 我尝试运行你的代码,并不能复现这个情况,您可以晚上一下代码吗?

抱歉,之前代码给的有误,我已修改。 示例项目代码实际上就是新建一个uni-ui项目,然后修改index.vue 录了个操作视频
QQ202534-222552.mp4

好的,感谢您的反馈,能够复现这个问题,我尝试看一下是什么导致的。

https://github.com/dcloudio/uni-ui/pull/989/files
我之前提交了修改的代码,不知道为啥没绑定上issues。
应该是_processReadonly中对结果的类型判断错了

@cucuzi
Copy link
Author

cucuzi commented Mar 7, 2025

还有个bug,就是readonly设置了map的话,也匹配不到数据。如果去掉readonly却又能匹配到数据。
代码示例:

<template>
  <view>
    <uni-data-picker v-model="temperature" readonly placeholder="请选择最高气温"
      :localdata="temperaturePicker" :map="{text:'label',value:'value'}"></uni-data-picker>
  </view>
</template>

<script>
  export default {
    data() {
      return {
        temperature: "25",
        temperaturePicker: []
      }
    },
    onLoad() {
      for (var i = 50; i > -41; i--) {
        this.temperaturePicker.push({
          label: `${i}℃`,
          value: `${i}`
        });
      }
    }
  }
</script>

预览:
Image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants