export default {
name:'xxx'
name:'xxx'
}
name的作用有三个:
1、当项目使用keep-alive时,可搭配组件name进行缓存过滤
<div id="app">
<keep-alive exclude="xxx">
<router-view/>
</keep-alive>
</div>
exclude="xxx"意思是排除xxx组件的缓存
2、dom树递归使用
<div>
<div v-for="(item,index) of list" :key="index">
<div>
<span class="item-title-icon"></span>
{{item.title}}
</div>
<div v-if="item.children" >
<detail-list :list="item.children"></detail-list>
</div>
</div>
</div>
<script>
export default {
name:'DetailList',//递归组件是指组件自身调用自身
props:{
list:Array
}
}
</script>
3、当你用vue-tools时
vue-devtools调试工具里显示的组见名称是由vue中组件name决定的