【vue】Prop being mutated: “placement“

问题现象:

控制台错误信息: [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”
【vue】Prop being mutated: “placement“_第1张图片
vue版本[email protected] (npm list 即可查看版本)

原因分析:

高于2.15.6版本的element-ui在date-picker组件新增了一行直接修改placement的代码

    this.placement = PLACEMENT_MAP[this.align] || PLACEMENT_MAP.left;

【vue】Prop being mutated: “placement“_第2张图片

【vue】Prop being mutated: “placement“_第3张图片

解决方法:

  1. 查看package.json文件中element-ui的版本号
    【vue】Prop being mutated: “placement“_第4张图片
  2. 版本号是以^开头(表示安装2.0最高版本),先卸载,再重装element-ui,即可解决
    npm uninstall element-ui
    npm install [email protected]
    

你可能感兴趣的:(vue,vue.js,javascript,ecmascript)