I'm using component ElDatepicker from element-ui and I want to change it's template and event handler method. I'm trying to do something like this in single file component:
import Vue from 'vue';
import ElDatePicker from 'element-datepicker'
Vue.use(ElDatePicker)
var dpkr = Vue.component('ElDatePicker')
console.log(dpkr)
export default {
extends: ['ElDatePicker']
}
But it doesn't work. How i can change it?
https://github.com/ElemeFE/element/tree/dev/packages/date-picker - component package
Extending Components The pattern we will highlight today is the extends option (part of the Vue options API) that allows us to compose components and share functionality throughout different parts of your UI in a manageable, concise pattern.
The best way to force Vue to re-render a component is to set a :key on the component. When you need the component to be re-rendered, you just change the value of the key and Vue will re-render the component.
To add external JavaScript scripts to Vue. js components, we can add a script element with document. createElement . export default { //... mounted() { const recaptchaScript = document.
Your main problem is that extends should specify a single component and not an array. You should reference the component and not the name.
import Vue from 'vue';
import ElDatePicker from 'element-datepicker'
export default {
extends: ElDatePicker
}
The repo you posted is from element-ui
Do npm install element-ui
Then:
import { DatePicker } from 'element-ui'
export default {
// Use mixins for array syntax
mixins: [DatePicker]
// OR use extends without array
extends: DatePicker
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With