vue+elementui选项卡简单应用

用法:
首先自己先在项目中定义三个组件(顶部TopNav,左侧LeftAside,中间Main),这方法三两句话描述不清

我就上我用过的一个项目代码实例(但是这个有点缺陷,没有做像一键清空选项卡,关闭左右侧选项卡的方法)

TopNav

<template>
	<el-menu class="el-menu-demo" mode="horizontal" background-color="#334157" text-color="#fff" active-text-color="#fff">
		<el-button class="buttonimg">
			<img class="showimg" :src="collapsed?imgshow:imgsq" @click="doToggle()">
			<!-- :src="collapsed?imgshow:imgsq" @click="doToggle()" -->
		</el-button>
		<el-submenu index="2" class="submenu">
			<template slot="title">当前用户【{
  {username}}】身份认证:{
  {usertype}}</template>
			<el-menu-item index="2-1">设置</el-menu-item>
			<el-menu-item index="2-2" @click="mya()">个人中心</el-menu-item>
			<el-menu-item @click="exit()" index="2-3">退出</el-menu-item>
		</el-submenu>
	</el-menu>
</template>

<script>
	export default {
		name: 'LeftAside',
		data: function() {
			return {
				collapsed: false, //是否折叠
				imgshow: require('../assets/img/show.png'),
				imgsq: require('../assets/img/sq.png'),
				username:sessionStorage.getItem("username"),
				usertype:sessionStorage.getItem("deptment")
			};
		},
		methods: {
			doToggle() {
				this.collapsed = !this.collapsed;
				console.log("TopNav的collapsed=%s", this.collapsed);
				this.$emit('top-click', this.collapsed);
			},
			exit() {
				this.$confirm('亲,请不要走,留下好不好?', '提示', {
					confirmButtonText: '残忍离开',
					cancelButtonText: '留下~',
					type: 'warning'
				}).then(() => {
					this.$router.push('/');

				}).catch(() => {});
			},
      mya(){
        /* this.$router.push('/userCenter'); */
         /* this.$router.push('/system/UserCenter'); */
      }
		}
	}
</script>

<style scoped>
	.el-menu-vertical-demo:not(.el-menu--collapse) {
		border: none;
	}

	.submenu {
		float: right;
	}

	.buttonimg {
		height: 60px;
		background-color: transparent;
		border: none;
	}

	.showimg
  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值