3

I have a nested structure with vue:

<app>
  <column> : [array]
    <task> : [array]
      <resource> : [array]

I'm also using single file components. For <app> component it looks like this (/App.vue file)

<template>
  <div id="app">
     <column v-for=""></column>
  </div>
</template>

<script>
  import column from './components/Column'

  export default {
    name: 'project',
    components: {
      column
    },  
    data () {
      return {

      }
    }
  }
</script>

The <column> component (/components/Column.vue file):

<template>
  <div>
      <task v-for=""></task>
  </div>
</template>

<script>
  import task from './Task'

  export default {
    name: 'column',
    components: {
      task
    },
    data () {
      return {

      }
    }
  }
</script>

The <task> component (/components/Task.vue file):

<template>
  <div>
      <resources></resources>
  </div>
</template>

<script>
  import { resources } from './Init-resource'

  export default {
    name: 'task',
    components: {
      resources
    },
    data () {
      return {

      }
    }
  }
</script>

Up until this point everything works flawlessly. The app renders a bunch of columns, and inside the columns it renders tasks. But then comes another layer <resource>, that looks like this (/components/Init-resource.vue file):

<template>
  <div>
    <select>
      <option v-for=""></option>
    </select>
  </div>
</template>

<script>
  export default {
    name: 'resources',
    data () {
      return {

      }
    }
  }
</script>

I get this error:

vue.common.js?e881:509 [Vue warn]: Unknown custom element: <resources> - did you register the component correctly? For recursive components, make sure to provide the "name" option. 
(found in component <task>

It doesn't recognize the last <resource> component. But everything looks fine, imports are correct, components are returned for the template...

1 Answer 1

7

I found it. I used named import, so instead of this:

import { resources } from './Init-resource'

it should be this:

import resources from './Init-resource'
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.