美文网首页
Element-ui 日期组件ElDatePicker 报错u

Element-ui 日期组件ElDatePicker 报错u

作者: 一个健康马 | 来源:发表于2022-12-25 16:08 被阅读0次

Element-ui 日期组件ElDatePicker
报错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"
这个报错并没有影响实际操作,但是看着很难受

报错截图_16720419875470.png

解决

main.js加入代码

import Vue from 'vue'
import Element from 'element-ui'
function RepairProps(cmp) {
  (cmp.mixins || []).forEach(mixin => {
  if (mixin.props && mixin.props.placement) {
  const defaultValue = mixin.props.placement.default
  mixin.data = new Proxy(mixin.data, {
  apply(target, thisArg, argArray) {
  const res = Reflect.apply(target, thisArg, argArray)
  return {
  ...(res || {}),
  placement: defaultValue
  }
  }
  })
  delete mixin.props.placement
  }
  if (mixin.mixins && mixin.mixins.length > 0) {
  RepairProps(mixin)
  }
  })
  }
  
  RepairProps(Element.DatePicker)
  RepairProps(Element.TimePicker)
  RepairProps(Element.TimeSelect)
  
  Vue.use(Element, {
  size: 'medium'
  }) 

相关文章

网友评论

      本文标题:Element-ui 日期组件ElDatePicker 报错u

      本文链接:https://www.haomeiwen.com/subject/kydgqdtx.html