I'm using ponent 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 ponent:
import Vue from 'vue';
import ElDatePicker from 'element-datepicker'
Vue.use(ElDatePicker)
var dpkr = Vueponent('ElDatePicker')
console.log(dpkr)
export default {
extends: ['ElDatePicker']
}
But it doesn't work. How i can change it?
- ponent package
I'm using ponent 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 ponent:
import Vue from 'vue';
import ElDatePicker from 'element-datepicker'
Vue.use(ElDatePicker)
var dpkr = Vue.ponent('ElDatePicker')
console.log(dpkr)
export default {
extends: ['ElDatePicker']
}
But it doesn't work. How i can change it?
https://github./ElemeFE/element/tree/dev/packages/date-picker - ponent package
Share Improve this question edited Feb 5, 2017 at 8:45 Dan asked Feb 5, 2017 at 6:55 DanDan 1511 silver badge5 bronze badges 2- Yep, I need to change it's functionality, but I don't know how to – Dan Commented Feb 5, 2017 at 13:01
- Does this answer your question? How do I extend another VueJS ponent in a single-file ponent? (ES6 vue-loader) – ChewySalmon Commented Jul 31, 2020 at 12:48
2 Answers
Reset to default 2Your main problem is that extends should specify a single ponent and not an array. You should reference the ponent 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
}
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
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745344711a4623490.html
评论列表(0条)