Answer the question
In order to leave comments, you need to log in
Vue component. How to pass a template from import to template?
If so, then it works:
// Работает
Vue.component('my-component', {
template: '<div>555</div>'
});
import Example from './components/Example.vue'
// test
Vue.component('my-component', {
template: Example
});
[Vue warn]: invalid template option:[object Object]
<template>
<div>
I'm an example component!
</div>
</template>
<script>
export default {
mounted() {
console.log('Component mounted.')
}
}
</script>
Answer the question
In order to leave comments, you need to log in
import Example from './components/Example.vue'
// test
Vue.component('my-component', Example);
npm install vue-cli -g
vue-init webpack-simple testproject
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question