在Vue中创建一个侧边栏(Sidebar)是一个常见的需求,特别是在构建管理界面或需要导航菜单的应用时。侧边栏通常用于展示应用的导航链接或菜单项,用户可以通过点击这些链接来访问应用的不同部分。
<template>
<el-tree :data="data" :props="defaultProps" class="node-name" @node-click="handleNodeClick" >
<template v-slot="{ node, data }">
<span>
<img :src="getIconSrc(data)" style="width: 16px; height: 16px; margin-right: 8px;" >
{{ node.label }}
</span>
</template>
</el-tree>
</template>
<script >
export default {
data() {
return {
data: [{
label: '美团',
iconSrc: 'data:image/svg+xml;base64,PHN2ZyB0PSIxNjc4MzQ0MzY0ODUyIiBjbGFzcz0iaWNvbiIgdmlld0JveD0iMCAwIDEwMjQgMTAyNCIgdmVyc2lvbj0iMS4xIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHAtaWQ9IjEyOTIzIiB3aWR0aD0iMjAwIiBoZWlnaHQ9IjIwMCI+PHBhdGggZD0iTTkyMiA5MTAuNUgxMDJjLTIxLjkgMC0zOS42LTE3LjctMzkuNi0zOS42VjIyNC4zYzAtMjEuOSAxNy43LTM5LjYgMzkuNi0zOS42aDgyMGMyMS45IDAgMzkuNiAxNy43IDM5LjYgMzkuNnY2NDYuNmMwIDIxLjgtMTcuOCAzOS42LTM5LjYgMzkuNnoiIGZpbGw9IiNGRkEwMDAiIHAtaWQ9IjEyOTI0Ij48L3BhdGg+PHBhdGggZD0iTTUxMiAzNTQuOUg2Mi40VjE1My4xYzAtMjEuOSAxNy43LTM5LjYgMzkuNi0zOS42aDMwNy43YzE3LjUgMCAzMi45IDExLjQgMzcuOSAyOC4yTDUxMiAzNTQuOXoiIGZpbGw9IiNGRkEwMDAiIHAtaWQ9IjEyOTI1Ij48L3BhdGg+PHBhdGggZD0iTTg1OS43IDg2MS4zSDE2NC4zYy0yMS45IDAtMzkuNi0xNy43LTM5LjYtMzkuNnYtNTM3YzAtMjEuOSAxNy43LTM5LjYgMzkuNi0zOS42aDY5NS41YzIxLjkgMCAzOS42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MzMzMyAyMS4zMzMzMzMgMCAwIDEgMjEuMzMzMzM0IDIxLjMzMzMzM3oiIGZpbGw9IiM1QzVDNjYiIHAtaWQ9IjEzMzM3Ij48L3BhdGg+PC9zdmc+', // 图片路径
}]
}],
defaultProps: {
children: 'children',
label: 'label'
}
};
},
methods:{
handleNodeClick(data) {
console.log(data);
},
getIconSrc(node){
return node.iconSrc ? node.iconSrc : ''; // 返回节点自定义的图片路径,如果没有则返回空字符串
}
}
};
</script>
<style scoped lang="scss">
.mg-member-tree .custom-tree-node .node-name {
margin-top: 2px;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
</style>