Vue component inside another component

Viewed 1476

Quick question about vue components. So can i do this?

App.vue file > import test.vue component in app.vue> import test2.vue component in test.vue

I get a Failed to compile error. Thanks.

app.vue:

import test from './components/test.vue';

export default {
  components: {
    'app-test': test,
  }
}

test.vue:

import test2 from './components/test2.vue';

export default {
  components: {
    'app-test2': test2,
  }
}
3 Answers

Try to replace

import test2 from './components/test2.vue';

by

import test2 from 'test2.vue';

or

import test2 from './test2.vue';

try without ";" I'm not use that, so it could works

import test2 from './components/test2.vue'

What worked for me is the one below if both components are in the same level directory:

import test2 from "components/test2.vue";
Related