1、首页
(1)client/src/views里面新建Home.vue
<template>
<div class="home">
<div class="container">
<h1 class="title">购课在线</h1>
<p class="lead">专注于线上教育,用心做课程,用心做服务!</p>
</div>
</div>
</template>
<script>
export default {};
</script>
<style scoped>
.home {
width: 100%;
height: 100%;
background: url(../assets/showcase.jpg) no-repeat;
background-size: 100% 100%;
}
.container {
width: 100%;
height: 100%;
box-sizing: border-box;
padding-top: 100px;
background-color: rgba(0, 0, 0, 0.7);
text-align: center;
color: white;
}
</style>
(2)给Home.vue设置路径
-
引入
import Home from './views/Home'
在client/src/router.js里面
-
配置
在组件index下面配置子组件,因为是index的子组件
{ path:'/index', name:'index', component:Index, children:[ {path:'',component:Home}, {path:'/home',name:'home',component:Home} ] }
(3)client/src/views/index.vue里面引入并使用
<template>
<div class="index">
<HeadNav></HeadNav>
<router-view></router-view>
</div>
</template>
<script>
import HeadNav from '../components/HeadNav'
export default {
name:'index',
components: {
HeadNav,
}
}
</script>
<style>
.index{
width: 100%;
height: 100%;
overflow: hidden;
}
</style>
其中:<router-view></router-view>就是使用的Home.vue模块
效果图:
首页效果图2、个人信息
-
设置路径 (client/src/router.js中)
import InfoShow from "./views/InfoShow"
{path:'/infoshow',name:'infoshow',component:InfoShow}
-
client/src/views下新建 InfoShow.vue文件
<template> <div class="infoshow"> <el-row type="flex" class="row-bg" justify="center"> <el-col :span="8"> <div class="user"> <img :src="user.avatar" class="avatar"> </div> </el-col> <el-col :span="16"> <div class="userinfo"> <div class="user-item"> <i class="fa fa-user"></i> <span>{{user.name}}</span> </div> <div class="user-item"> <i class="fa fa-cog"></i> <span>{{user.identity == "manager" ? "管理员":"普通员工"}}</span> </div> </div> </el-col> </el-row> </div> </template> <script> export default { name:'infoshow', computed: { user(){ return this.$store.getters.user; } } } </script> <style scoped> .infoshow{ width: 100%; height: 100%; box-sizing: border-box; } .row-bg{ width: 100%; height: 100%; } .user{ text-align: center; position: relative; top: 30%; } .user img{ width: 150px; border-radius: 50%; } .user span{ display: block; text-align: center; margin-top: 20px; font-size: 20px; font-weight: bold; } .userinfo{ height: 100%; background-color: #eee; } .user-item{ position: relative; top: 30%; padding: 26px; font-size: 28px; color: #333; } </style>
-
client/public/index.html中引入样式,因为上面的InfoShow.vue组件用到了
<link rel="stylesheet" href="//cdn.bootcss.com/font-awesome/4.7.0/css/font-awesome.css">
-
修改跳转到个人信息的代码
打开client/src/components/HeadNav.vue,修改方法中的跳转
showInfoList(){ // console.log("个人信息"); this.$router.push("/infoshow"); }
-
效果图
网友评论