添加链接
link管理
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接
Collectives™ on Stack Overflow

Find centralized, trusted content and collaborate around the technologies you use most.

Learn more about Collectives

Teams

Q&A for work

Connect and share knowledge within a single location that is structured and easy to search.

Learn more about Teams

I'm facing an issue with my first Vue Project. I already googled for a while but can't find something very usefull.

I simply try to create a parent ("Files") and a child component ("Filelist") and use the Filelist in Files. This is not working as expected. I can't see the mistake, beacause i already added

export default {
  name: 'Filelist',

The only hint I can get is from the browser console

[Vue warn]: Unknown custom element: <Filelist> - did you register the component correctly? For recursive components, make sure to provide the "name" option.
found in
---> <Files> at src/docs/categories/Files.vue
       <App> at src/App.vue
./src/App.vue (./node_modules/babel-loader/lib!./node_modules/vue-loader/lib/selector.js?type=script&index=0!./src/App.vue) 42:14-22"
export 'Filelist' was not found in '@/components/Filelist'

Thanks a lot in advance

The code of Files:

<template>
  <div class="">
    <h1>Hedajo</h1>
    <Filelist :msg="sometext"/>
    {{ sometext }}
</template>
<script>
import { Filelist } from "@/components/Filelist.vue";
export default {
  name: "Files",
  components: {
    Filelist
  data() {
    return {
      sometext: "hejo",
  methods: {
</script>
<style scoped>
</style>

The code of Filelist:

<template>
  <component class="">
    {{ msg }}
    <p>hewhwe</p>
    {{ hedadi }}
    {{ testi }}
  </component>
</template>
<script>
export default {
  name: 'Filelist',
  props: ["msg"],
  data () {
    return {
      testi: "hedadi",
</script>
<style scoped>
</style>
                Wow :D Thank you really much. When do i need { }? 6 min and i can mark your answer as correct
– RacoonOnMoon
                Jan 3, 2019 at 10:50
                You can use the { } Syntax to import named exports. So if you would have something like export class MyClass {}, then you would import it with import {MyClass} from '...'. For more details, see: stackoverflow.com/questions/36795819/…
– Aseider
                Jan 3, 2019 at 10:54
<script>
import Vue from 'vue';
Vue.component('Filelist', require('@/components/Filelist.vue').default);

You dont need the import Filelist statement in this case

Thanks for contributing an answer to Stack Overflow!

  • Please be sure to answer the question. Provide details and share your research!

But avoid

  • Asking for help, clarification, or responding to other answers.
  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.