export default new VueRouter({ routes:[ { name:"login", path:"/MyLogin", component: myLogin }, { name:"signin", path:"/SignIn", component: signIn } ] })有问题吗、
时间: 2024-02-10 14:12:02 浏览: 31
这段代码的问题不大,主要是用`VueRouter`来创建路由并配置路由的信息,其中`routes`数组中包含了两个路由对象,分别是`/MyLogin`和`/SignIn`。这两个路由对象分别对应两个组件`myLogin`和`signIn`。
不过,需要注意的是,在使用`VueRouter`时,需要先安装`vue-router`插件,然后在Vue的入口文件中引入并使用该插件。
例如,在main.js中可以这样引入和使用VueRouter插件:
```
import Vue from 'vue'
import VueRouter from 'vue-router'
import App from './App.vue'
import myLogin from './components/myLogin.vue'
import signIn from './components/signIn.vue'
Vue.use(VueRouter)
const router = new VueRouter({
routes: [
{
name: 'login',
path: '/MyLogin',
component: myLogin
},
{
name: 'signin',
path: '/SignIn',
component: signIn
}
]
})
new Vue({
router,
render: h => h(App)
}).$mount('#app')
```
这样就可以正常使用VueRouter进行页面跳转了。
相关推荐
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)