navSub.vue
根
/
temp /
site-admin-iview /
main /
page /
navSub.vue
<style lang="less" scoped>
.tab-box{
background-color: #ffffff;border-bottom: #aaa 1px solid; line-height: 34px;font-size:16px;
height: 36px; padding: 0 20px;
>div{ float: left; height: 36px; padding: 2px 20px 0 20px; cursor: pointer;}
.active{border-bottom: 3px solid #2d8cf0; color: #2d8cf0;}
}
</style>
<template>
<div class="tab-box" v-if="list.length>0">
<div v-for="(item,index) in list" @click="onClick(index)" :class="navIndex == index ?'active':''">{{item.title}}
</div>
</div>
</template>
<script type="text/javascript">
import navConfig from '../config/navConfig.js';
export default {
props: {
activeName: {
type: String,
default: ''
}
},
data() {
return {
navIndex: 0,
navConfig,
list: []
};
},
components: {},
methods: {
setNav(name) {
var array = name.split('-');
try {
let list = this.navConfig[array[0]].children[array[1]].children;
this.list = list || [];
} catch (ex) {
this.list = [];
}
},
onClick(index) {
this.navIndex = index;
this.$router.push({ path: this.list[this.navIndex].to });
}
},
watch: {
activeName(val, oldname) {
this.setNav(val);
}
},
created() {
this.setNav(this.activeName);
},
mounted() {},
//计算属性
computed: {}
};
</script>