Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/hibernate/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Vue.js 使用Vuejs实现可重用的选项卡式组件_Vue.js_Vue Component - Fatal编程技术网

Vue.js 使用Vuejs实现可重用的选项卡式组件

Vue.js 使用Vuejs实现可重用的选项卡式组件,vue.js,vue-component,Vue.js,Vue Component,我试图在vueJs中实现一个选项卡式可重用组件,但我遇到一个错误,即没有定义特定的组件。下面是两个组件 //TabComponent <template> <div> <div class="row"> <div class="col-lg-12 col-xl-12"> <div class="card-box"> &

我试图在
vueJs
中实现一个选项卡式可重用
组件
,但我遇到一个错误,即没有定义特定的组件。下面是两个组件

//TabComponent
<template>
    <div>
        <div class="row">
            <div class="col-lg-12 col-xl-12">
                <div class="card-box">
                    <ul class="nav nav-tabs nav-bordered">
                        <li v-for="tab in tabs" :key="tab" class="nav-item">
                            <a href="javascript:;"  @click="selectedComponent = tab" data-toggle="tab" aria-expanded="false"  :class="['nav-link', { active: selectedComponent === tab }]"> {{tab}} </a>
                        </li> 
                    </ul>
                    <div class="tab-content">
                        <component :is="selectedComponent"></component>
                    </div>
                </div>
            </div>
        </div>

    </div>
</template>

<script>
export default {
    name: 'TabComponent',
    props: [ selectedComponent, tabs ] //The error is coming from this line
}
</script>
HTML属性名称不区分大小写,因此浏览器将解释 任何大写字符均为小写。这意味着当你使用 在DOM模板中,camelCased道具名称需要使用其kebab-cased (以连字符分隔的)等效项()

尝试:



编辑

如果将道具定义为数组,请使用字符串更改列表(请参见“道具类型”):

props:['selectedComponent','tabs']

'List'
中删除引号?相同错误@deppermadd
.vue
到导入行相同错误。。。错误来自
选项卡component
请参阅关于设置
selectedComponent的默认值
//Entitlements component
<template>
    <div>
        <tab-component :tabs="tabs" :selectedComponent="selectedComponent" />
    </div>
</template>

<script>
import TabComponent from "../../../components/TabComponent";
import List from "./Entitlements/List";
import MyEntitlements from "./Entitlements/MyEntitlements";
export default {
    name: 'Entitlements',

    components: {List, MyEntitlements, TabComponent},

    data(){
        return{
            tabs: ['List', 'MyEntitlements'],
            selectedComponent: 'List',
        }
    }
}
</script>