element-plus [Component] [date-picker] v-show not work on el-date-picker

wlp8pajw  于 6个月前  发布在  其他
关注(0)|答案(2)|浏览(78)

Bug Type: Component

Environment

  • Vue Version: 3.3.4
  • Element Plus Version: 2.3.1
  • Browser / OS: 版本 114.0.5735.134(正式版本) (64 位)/ Windows
  • Build Tool: Webpack

Reproduction

  • el-date-picker

Element Plus Playground

Steps to reproduce

hide
show

What is Expected?

v-show can work on

What is actually happening?

v-show not work on el-date-picker by switching radio

Additional comments

(empty)

fnatzsnv

fnatzsnv1#

The reason should be that el-tooltip is used as the root node and the v-show cannot be hung. As a temporary solution, it is recommended to wrap a layer of div outside el-data-picker .

e1xvtsh3

e1xvtsh32#

正如楼上说的,el-date-picker 本质上是el-tooltip包了一个el-input组件,el-tooltip会穿梭到最外面,剩下页面能看到的就是el-input组件,而el-input组件没有完全接受外层传入的属性,也就是没有v-bind="$attrs"这个,再加上本身他有v-show的判断。所以不能支持v-show

解决方案如下
1 自己业务中外层加个div控制
2 用v-if控制
3 让el官方大佬给你改源码,把属性层层传递到el-input上,然后进行合并判断即可

相关问题