Vue:重定向(可以带参数)
在index.jsimport Vue from 'vue'import Router from 'vue-router'import HelloWorld from "../components/HelloWorld";import Hi1 from "../components/Hi1";import Hi2 from "../components/Hi2";import para...
·
在index.js
import Vue from 'vue'
import Router from 'vue-router'
import HelloWorld from "../components/HelloWorld";
import Hi1 from "../components/Hi1";
import Hi2 from "../components/Hi2";
import params from "../components/params";
Vue.use(Router)//vue全局使用Router
export default new Router({
routes: [//参数为数组
{
path:"/goHome",
redirect:'/' //重定向到首页
}
]
})
app.vue中
<template>
<div id="app">
<img src="./assets/logo.png">
<router-link to="/">首页</router-link> |
<router-link to="/goHome">回首页</router-link> |//重定向回到首页
<router-view/>
</div>
</template>
<script>
export default {
name: 'App'
}
</script>
<style>
#app {
font-family: 'Avenir', Helvetica, Arial, sans-serif;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
text-align: center;
color: #2c3e50;
margin-top: 60px;
}
</style>
更多推荐
已为社区贡献1条内容
所有评论(0)