如果icon的地址是相对于项目根目录的路径,
动态引入图片地址时需要添加require()
动态生成menu
javascript
<el-menu default-active="2" class="el-menu-vertical-demo" @open="handleOpen" @close="handleClose"
:collapse="isCollapse">
<el-menu-item :index="mindex+1" v-for="(mitem,mindex) in menuList" :key="mindex">
<img :src="mitem.icon" alt="">
<span slot="title">{{mitem.name}}</span>
</el-menu-item>
</el-menu>
menuList
javascript
menuList:[
{name:'数据概览',icon:require('@/assets/img/global/menu11.png'),iconActive:require('@/assets/img/global/menu12.png')},
{name:'数据引接',icon:require('@/assets/img/global/menu11.png'),iconActive:require('@/assets/img/global/menu12.png')},
{name:'数据检索',icon:require('@/assets/img/global/menu11.png'),iconActive:require('@/assets/img/global/menu12.png')},
{name:'数据重组',icon:require('@/assets/img/global/menu11.png'),iconActive:require('@/assets/img/global/menu12.png')},
{name:'系统管理',icon:require('@/assets/img/global/menu11.png'),iconActive:require('@/assets/img/global/menu12.png')},
]