<template>
<div id="myapp">
<!-- 第1行 -->
<div class="left">
<router-link class="box_1" to="/Box_1" active-class="active">
打开Box_1组件
</router-link>
<router-link class="box_2" to="/Box_2" active-class="active">
打开Box_2组件
</router-link>
</div>
<div class="right">
<Box_1></Box_1>
</div>
<br />
</div>
</template>
<script>
// 引入组件
import Box_1 from "./components/Box_1";
// import Box_2 from "./components/Box_2.vue";
// 注册组件
export default {
name: "App",
components: {
Box_1,
// Box_2,
},
data() {
return {};
},
methods: {
getInfo(a, b) {
this.appSchoolName = a;
this.appAddress = b;
},
},
mounted() {},
};
</script>
<style scoped>
body {
margin: 0;
padding: 0;
background-color: rgb(147, 149, 149);
}
a:link {
color: #ff0000;
text-decoration: none;
}
#myapp {
display: flex;
flex-direction: row;
}
.left {
width: 0px;
height: 100px;
flex-grow: 4;
padding-top: 10px;
/* background-color: rgb(255, 220, 220); */
}
.box_1 {
display: block;
width: 150px;
height: 50px;
line-height: 50px;
text-align: center;
border: 1px rgb(224, 224, 224) solid;
border-top-left-radius: 10px;
border-top-right-radius: 10px;
}
.box_2 {
display: block;
width: 150px;
height: 50px;
line-height: 50px;
text-align: center;
margin-top: -1px;
border: 1px rgb(224, 224, 224) solid;
border-bottom-left-radius: 10px;
border-bottom-right-radius: 10px;
}
.box_select {
background-color: red;
}
.right {
width: 0px;
height: 100px;
flex-grow: 6;
}
.active {
background-color: rgb(22, 122, 214);
color: white;
}
</style>
【Vue】路由组件通过router-link设置css样式及active单击样式
猜你喜欢
转载自blog.csdn.net/dxnn520/article/details/125083228
今日推荐
周排行