现有组件抛出:未知自定义元素
2017-03-14
728
我试图在另一个组件中使用一个组件。在
created
事件中,我可以记录此组件并返回好对象。但是由于某些原因,该组件似乎未包含在内。VueJS 不理解
validation
标签。
有什么想法吗?
<template>
<main>
<validation :validate="$v.email" :model="'email'"></validation>
</main>
</template>
<script>
import { Validation } from 'components/helpers'
export default {
name: 'login',
component: { Validation },
created() {
// it works. print the component with his path
window.console.log(Validation)
}
}
</script>
[Vue warn]: Unknown custom element: - did you register the component correctly? For recursive components, make sure to provide the "name" option.
在
components/helpers
中我有两个文件:
1) index.js
export { default as Validation } from './Validation'
2) Validation.vue
<template>
<div>
<span class="form__validation" v-if="validate && !validate.required">Required</span>
<template v-if="validation[model]">
<span class="form__validation" v-for="error in validation[model].messages">{{ error }}</span>
</template>
</div>
</template>
<script>
import { mapGetters } from 'vuex'
export default {
name: 'validation',
data() {
return {
L: L
}
},
props: ['model', 'validate'],
computed: {
...mapGetters({
validation: 'getValidation'
})
}
}
</script>
1个回答
将
component
更改为
components
即可解决问题。我感到很惭愧 :)
Gabriel Robert
2017-03-15