1.在components文件下创建相关组件如(breadcrumb.vue)
<template>
<div>
<el-breadcrumb separator-class="el-icon-arrow-right">
<el-breadcrumb-item :to="{ path: '/home' }">首页</el-breadcrumb-item>
<el-breadcrumb-item>{{breadName}}</el-breadcrumb-item>
<el-breadcrumb-item>{{breadValue}}</el-breadcrumb-item>
</el-breadcrumb>
</div>
</template>
<script>
export default {
name: 'breadcrumb',
props: {
breadName: {
// 规定传值为字符串 默认的名字
type: String,
default: '默认的name'
},
breadValue: {
type: String,
default: '默认的value'
}
}
}
</script>
<style scoped>
</style>
2.main文件 全局注册
import Bread from './components/breadcrumb/breadcrumb.vue' Vue.component('Bread', Bread)
3.使用全局组件
<template> <div> <!-- 面包屑东导区域--> <Bread :breadName="'999'" :breadValue="'666'"></Bread> </div> </template> <script> export default { name: 'Rights' } </script> <style scoped> </style>