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

[Component] [date-picker, time-picker] 修改 el-input 的 props 的 clearable 的默认属性为 true 后,el-date-picker 和 el-time-picker 默认情况下会出现 2个 清空符号 #16672

Open
yzj940619 opened this issue Apr 26, 2024 · 2 comments · May be fixed by #16690

Comments

@yzj940619
Copy link

Bug Type: Component

Environment

  • Vue Version: 3.4.15
  • Element Plus Version: 2.7.1
  • Browser / OS: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/124.0.0.0 Safari/537.36
  • Build Tool: Vite

Reproduction

Related Component

  • el-date-picker
  • el-time-picker

Reproduction Link

Element Plus Playground

Steps to reproduce

<script setup lang="ts"> import { ref } from 'vue' import { ElInput } from 'element-plus' Object.assign(ElInput.props.clearable, { default: true }) const msg = ref('Hello World!') const date = ref() const time = ref() </script>

What is Expected?

修改 el-input 的 clearable 默认属性后,不应该影响到其他组件。

What is actually happening?

修改 el-input 的 clearable 默认属性后,影响到el-date-picker和 el-time-picker。

Additional comments

查看源码后,el-date-picker 和 el-time-picker组件都有用到picker.vue组件(“element-plus/packages/components/time-picker/src/common
/picker.vue”),其中使用到的 el-input 组件并没有显式传入 :clearable ="false" 属性

@GUEThe
Copy link

GUEThe commented Apr 26, 2024

本质是 input 的默认 Props 被更改了(Object.assign(ElInput.props.clearable, { default: true })),对象引用,更改了这个值,其他地方新建的 el-input 也会生效。建议优先配置 :clearable="false"

@yzj940619
Copy link
Author

本质是 input 的默认 Props 被更改了(Object.assign(ElInput.props.clearable, { default: true })),对象引用,更改了这个值,其他地方新建的 el-input 也会生效。建议优先配置 :clearable="false"

嗯,对的,直接在picker.vue这个组件文件中显式配置 :clearable="false"是最便捷的解决方案

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