element
element copied to clipboard
date-picker: fix modify props "placement" error
!!! This error is on the current production version 2.15.9 , please quick fix
fix this error

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
The same error...
这个方法并不能解决问题
我也遇到这个问题了
为什么我element 2.15.6也有这个问题
Element UI version fallback to 2.15.7
npm uninstall element-ui npm i [email protected] -s
it works!!!!!! THANKS! :3
This issue occurs again in 2.15.9.
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",
Version 2.15.8 doesn't have this error, can use it
> npm uninstall element-ui
> npm install [email protected] -s
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
};
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
俺也一样,别用2.15.9,用2.15.7或者2.15.8
@lqzhgood 你好,我是element-ui官方维护团队的xinguanhua,非常感谢你以pr的方式,为element-ui组件库的完善贡献了一份力量。element-ui有一份礼物将会寄给你,希望能够提供寄件地址及联系方式,可以发送邮件到 [email protected]。
@lqzhgood 你好,我是 element-ui 官方维护团队的 xinguanhua,非常感谢你以 pr 的方式,为 element-ui 组件库的完善贡献了一份力量。element-ui 有一份礼物将会寄给你,希望能够提供寄件地址及联系方式,可以发送邮件到 [email protected]。
邮件已发送