Vue-class-component: Setting name in Component decorator does not work

Created on 2 Jul 2017  路  3Comments  路  Source: vuejs/vue-class-component

Here is my current code that works, because I explicitly register the component
(this is the

All 3 comments

@championswimmer

We have to register a component constructor explicitly to use.

Vue.component('todo-list-item', TodoListItem)

or

@Component({
  components : { TodoListItem }
})
export default class TodoList extends Vue {
}

And, name option is not related to registering components.
https://vuejs.org/v2/api/#name

@Component decorator automatically set class name (for instance, TodoListItem in your case) to name option.

Okay ! Thanks ! That solves my problem !

declare className as you component鈥榮 name, this worked for me well

<template>
    <div class='warp'>
            <div  v-for="(widget, index) in data" :key="index"></div>
                <div>show something !</div>
                <my-widget v-if="widget.length >0" :data="widget" ></my-widget>
           </div>
    </div>
</template> 

<script lang="ts">
import { Vue, Component, Prop } from 'vue-property-decorator'
@Component({})
export default class MyWidget extends Vue {
    @Prop()data!: any
}
</script>
Was this page helpful?
0 / 5 - 0 ratings

Related issues

tonypee picture tonypee  路  6Comments

nqthiep picture nqthiep  路  6Comments

vishr picture vishr  路  3Comments

silkentrance picture silkentrance  路  6Comments

backbone87 picture backbone87  路  4Comments