14

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

2

2 Answers 2

2

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
}
Sign up to request clarification or add additional context in comments.

Comments

0

You have to first install Element UI in your project using npm install element-ui. Then you have to edit your main.ts/main.js file and add

import ElementUI from 'element-ui';
import 'element-ui/lib/theme-chalk/index.css';

Vue.use(ElementUI);

This should solve your problem. For more help, check Element UI

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.