|
@@ -1,32 +1,60 @@
|
|
|
<template>
|
|
|
<div>
|
|
|
- 主页
|
|
|
<!-- 3.使用组件 -->
|
|
|
- <Demo1></Demo1>
|
|
|
+ <!-- <Demo1></Demo1>
|
|
|
<Demo2></Demo2>
|
|
|
<p ref="aaa">你好</p>
|
|
|
- <button @click="getMain">获取</button>
|
|
|
+ <button @click="getMain">获取</button>-->
|
|
|
+ <!-- 声明式导航 -->
|
|
|
+ <div id="nav">
|
|
|
+ <router-link active-class="active" to="/home">首页</router-link>
|
|
|
+ <router-link active-class="active" to="/list">列表</router-link>
|
|
|
+ <router-link active-class="active" to="/my">我的</router-link>
|
|
|
+ </div>
|
|
|
+ <!-- 占位符 -->
|
|
|
+ <div id="main">
|
|
|
+ <router-view></router-view>
|
|
|
+ </div>
|
|
|
</div>
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
// 1.引入组件
|
|
|
-import Demo1 from './components/Demo1.vue';
|
|
|
-import Demo2 from './components/Demo2.vue';
|
|
|
+import Demo1 from "./components/Demo1.vue";
|
|
|
+import Demo2 from "./components/Demo2.vue";
|
|
|
export default {
|
|
|
// 2.注册组件
|
|
|
- components:{
|
|
|
+ components: {
|
|
|
Demo1,
|
|
|
Demo2
|
|
|
},
|
|
|
- methods:{
|
|
|
+ methods: {
|
|
|
getMain() {
|
|
|
- console.log(this.$refs.aaa)
|
|
|
+ console.log(this.$refs.aaa);
|
|
|
}
|
|
|
}
|
|
|
-}
|
|
|
+};
|
|
|
</script>
|
|
|
|
|
|
-<style>
|
|
|
-
|
|
|
+<style scoped lang="scss">
|
|
|
+#nav {
|
|
|
+ width: 90vw;
|
|
|
+ display: flex;
|
|
|
+ justify-content: space-around;
|
|
|
+ a {
|
|
|
+ font-size: 32px;
|
|
|
+ text-decoration: none;
|
|
|
+ color: #000;
|
|
|
+ font-weight: bold;
|
|
|
+ }
|
|
|
+}
|
|
|
+ #main {
|
|
|
+ width: 90vw;
|
|
|
+ height: 50vh;
|
|
|
+ border: 1px solid skyblue;
|
|
|
+ margin: 10px auto;
|
|
|
+ }
|
|
|
+ .active {
|
|
|
+ color: aquamarine !important;
|
|
|
+ }
|
|
|
</style>
|