element icon indicating copy to clipboard operation
element copied to clipboard

date-picker: fix modify props "placement" error

Open lqzhgood opened this issue 3 years ago • 10 comments

!!! This error is on the current production version 2.15.9 , please quick fix

fix this error image

vue.runtime.esm.js?2b0e:619 [Vue warn]: Avoid mutating a prop directly since the value will be overwritten whenever the parent component re-renders. Instead, use a data or computed property based on the prop's value. Prop being mutated: "placement"

found in

---> <ElDatePicker> at packages/date-picker/src/picker.vue

because this PR https://github.com/ElemeFE/element/pull/21806 add props placement to erroneously changed "placement" data -> props detail in issues https://github.com/ElemeFE/element/issues/21905

  • [x] Make sure you follow Element's contributing guide (中文 | English | Español | Français).
  • [x] Make sure you are merging your commits to dev branch.
  • [x] Add some descriptions and refer relative issues for you PR.

lqzhgood avatar Jun 06 '22 09:06 lqzhgood

The same error...

sugarnut001 avatar Jun 07 '22 08:06 sugarnut001

Element UI version fallback to 2.15.7

npm uninstall element-ui npm i [email protected] -s

55236339 avatar Jun 09 '22 01:06 55236339

这个方法并不能解决问题

trry-hub avatar Jun 09 '22 03:06 trry-hub

我也遇到这个问题了

cjy816618 avatar Jun 09 '22 07:06 cjy816618

为什么我element 2.15.6也有这个问题

a1292779206 avatar Jun 16 '22 03:06 a1292779206

为什么我element 2.15.6也有这个问题

npm uninstall element-ui

npm install [email protected]

这样试试,应该能解决你的问题

trry-hub avatar Jun 17 '22 00:06 trry-hub

Element UI version fallback to 2.15.7

npm uninstall element-ui npm i [email protected] -s

it works!!!!!! THANKS! :3

akmalov-i avatar Jun 18 '22 13:06 akmalov-i

This issue occurs again in 2.15.9.

fengzhang2011 avatar Jul 03 '22 22:07 fengzhang2011

Same warning here

I've updated my package.json file with the following to skip version 2.15.9 which has the props issue. This way when the next release comes out, it will get installed and hopefully not contain the issue.

"element-ui": ">2.15.9 || 2.15.8",

joshmakar avatar Jul 12 '22 13:07 joshmakar

Version 2.15.8 doesn't have this error, can use it

> npm uninstall element-ui
> npm install [email protected] -s

boluo700 avatar Aug 04 '22 08:08 boluo700

Removing the prop entirely from the NewPopper might cause some issue no?

Surely replacing the createdAt hook code that sets the value with a prop default value factory function would be more suitable?


const NewPopper = {
  props: {
    appendToBody: Popper.props.appendToBody,
    offset: Popper.props.offset,
    boundariesPadding: Popper.props.boundariesPadding,
    arrowOffset: Popper.props.arrowOffset,
    placement: {
      type: Popper.props.placement.type,
      default: function() {
        return PLACEMENT_MAP[this.align] || PLACEMENT_MAP.left;
      }
    },
    transformOrigin: Popper.props.transformOrigin
  },
  methods: Popper.methods,
  data() {
    return merge({ visibleArrow: true }, Popper.data);
  },
  beforeDestroy: Popper.beforeDestroy
};

dhemiwc avatar Aug 27 '22 03:08 dhemiwc

Removing the prop entirely from the NewPopper might cause some issue no?

Surely replacing the createdAt hook code that sets the value with a prop default value factory function would be more suitable?


const NewPopper = {
  props: {
    appendToBody: Popper.props.appendToBody,
    offset: Popper.props.offset,
    boundariesPadding: Popper.props.boundariesPadding,
    arrowOffset: Popper.props.arrowOffset,
    placement: {
      type: Popper.props.placement.type,
      default: function() {
        return PLACEMENT_MAP[this.align] || PLACEMENT_MAP.left;
      }
    },
    transformOrigin: Popper.props.transformOrigin
  },
  methods: Popper.methods,
  data() {
    return merge({ visibleArrow: true }, Popper.data);
  },
  beforeDestroy: Popper.beforeDestroy
};

Your suggestion is good The difference between them is: placement is a data or props the placement is not in the docs. if set in props need more test, so I think placement set a data is better.

and the code is 6 years old , I think is not have bug. https://github.com/ElemeFE/element/blob/06392ade7b9458d36d08f465ee5117bf39cb797b/packages/date-picker/src/picker.vue#L297


placement show in data is better. https://github.com/ElemeFE/element/blob/acfc93a71f8b67886f6f98e2f066858d685c6866/packages/date-picker/src/picker.vue#L399-L406

lqzhgood avatar Aug 27 '22 10:08 lqzhgood

俺也一样,别用2.15.9,用2.15.7或者2.15.8

barry1102 avatar Sep 05 '22 07:09 barry1102

Element UI 版本回退到 2.15.7

npm 卸载 element-ui npm i [email protected] -s

it work! thanks!

huangshihu1992 avatar Jan 04 '23 07:01 huangshihu1992

@lqzhgood 你好,我是element-ui官方维护团队的xinguanhua,非常感谢你以pr的方式,为element-ui组件库的完善贡献了一份力量。element-ui有一份礼物将会寄给你,希望能够提供寄件地址及联系方式,可以发送邮件到 [email protected]

xinguanhua avatar Feb 03 '23 02:02 xinguanhua

@lqzhgood 你好,我是 element-ui 官方维护团队的 xinguanhua,非常感谢你以 pr 的方式,为 element-ui 组件库的完善贡献了一份力量。element-ui 有一份礼物将会寄给你,希望能够提供寄件地址及联系方式,可以发送邮件到 [email protected]

邮件已发送

lqzhgood avatar Feb 03 '23 14:02 lqzhgood