Piter
Piter

Reputation: 57

vue faile to load mount component

I have to do some simple thing. I have to generate different select options to generate different data.

So I create component and I passing array with values, but only in theory xD

When I go to road i got error cold:

app.js:37990 [Vue warn]: Failed to mount component: template or render 
function not defined.

found in

---> <SelectComponent> at resources/js/components/SelectComponent.vue
   <ExampleComponent> at resources/js/components/ExampleComponent.vue
     <Root>

My component is simple for test do,

<h1> test connection </h1>
<script>
export default {
  name: 'SelectComponent',
  data () {
    return {}
  }
}
</script>

my main component

import SelectComponent from './SelectComponent.vue';

export default {
  components: {
    SelectComponent,
  },
  mounted() {
    console.log('Component mounted.')
  },
}

where is my issue?

Upvotes: 0

Views: 49

Answers (1)

Vucko
Vucko

Reputation: 20834

If you look at the documentation you'll see that the HTML should be wrapped in the <template> element. So change your component to:

<template>
  <h1> test connection </h1>
</template>

<script>
  export default {
    name: 'SelectComponent',
    data () {
     return {}
    }
  }
</script>

Upvotes: 2

Related Questions