If you have a vue component that is installed via Node :
node_modules/vendor/somecomponent.vue
Is there any way to modify/extend the template/methods of this component?
Update:
After trying out the example below, I'm facing this issue:
I am using https://github.com/eliep/vue-avatar and I need to extend this with a prop, and maybe amend the template a bit.
import {Avatar} from 'vue-avatar'
Avatar = Vue.component('Avatar').extend({
props: ['nationality']
});
export default {
components: {
Avatar
},
...
}
Results in TypeError: Cannot read property 'extend' of undefined
It doesn't appear to be documented specifically, but the
extend
method of Vue itself is available to components. You can override the template and add methods (and data and props).Avatar
appears to be a component spec, the simple JavaScript object that Vue will create a Component object from. Try this: