首页 >> js开发 >> jsvue设置默认首页的操作js大全
jsvue设置默认首页的操作js大全
发布时间: 2021年1月13日 | 浏览:
| 分类:js开发
在router.js设置如下:在router.js设置如下:index就是默认页面
const routes = [
// 公司项目
{ path: '/', redirect: '/index' },
{path:'/index',component:index},
{
path:'/example',
component:example,
redirect:'/edetail',
children:[
{path:'/edetail',component:edetail}
]
},
{path:'/login',component:login}
]
const routes = [
// 公司项目
{ path: '/', redirect: '/index' },
{path:'/index',component:index},
{
path:'/example',
component:example,
redirect:'/edetail',
children:[
{path:'/edetail',component:edetail}
]
},
{path:'/login',component:login}
]不使用在根目录设置router的方法,跳转页面带不同的头部信息时容易出现问题补充知识:vue-router默认的首页渲染设置补充知识:补充知识:vue-router默认的首页渲染设置当一个vue项目的页面打开,总得有一个默认的首页组件自动出现不能只是点击首页的跳转才出现这个默认的打开路由配置需要在router.js中的 VueRouter 实例中,改变routes数组
const router = new VueRouter({
routes:[
{
path:'/',
//redirect 是重新定向
redirect:'/home'
},
{
path:'/home',
component:Home
}
]
})
const router = new VueRouter({
routes:[
{
path:'/',
//redirect 是重新定向
redirect:'/home'
},
{
path:'/home',
component:Home
}
]
})这样设置之后,就将默认的路由路径设置为/home以上这篇vue设置默认首页的操作就是小编分享给大家的全部内容了,希望能给大家一个参考。
const routes = [
// 公司项目
{ path: '/', redirect: '/index' },
{path:'/index',component:index},
{
path:'/example',
component:example,
redirect:'/edetail',
children:[
{path:'/edetail',component:edetail}
]
},
{path:'/login',component:login}
]
const routes = [
// 公司项目
{ path: '/', redirect: '/index' },
{path:'/index',component:index},
{
path:'/example',
component:example,
redirect:'/edetail',
children:[
{path:'/edetail',component:edetail}
]
},
{path:'/login',component:login}
]不使用在根目录设置router的方法,跳转页面带不同的头部信息时容易出现问题补充知识:vue-router默认的首页渲染设置补充知识:补充知识:vue-router默认的首页渲染设置当一个vue项目的页面打开,总得有一个默认的首页组件自动出现不能只是点击首页的跳转才出现这个默认的打开路由配置需要在router.js中的 VueRouter 实例中,改变routes数组
const router = new VueRouter({
routes:[
{
path:'/',
//redirect 是重新定向
redirect:'/home'
},
{
path:'/home',
component:Home
}
]
})
const router = new VueRouter({
routes:[
{
path:'/',
//redirect 是重新定向
redirect:'/home'
},
{
path:'/home',
component:Home
}
]
})这样设置之后,就将默认的路由路径设置为/home以上这篇vue设置默认首页的操作就是小编分享给大家的全部内容了,希望能给大家一个参考。
相关文章:
- jsnuxt 自定义 auth 中间件实现令牌的持久化操作js大全
- jsantd中table展开行默认展示,且不需要前边的加号操作js大全
- jsvue缓存之keep-alive的理解和应用详解js大全
- js解决vue项目打包上服务器显示404错误,本地没出错的问题js大全
- jsvue项目打包后请求地址错误/打包后跨域操作js大全
- js解决Mint-ui 框架Popup和Datetime Picker组件滚动穿透的问题js大全
- js通过实例了解Render Props回调地狱解决方案js大全
- jsvant-ui组件调用Dialog弹窗异步关闭操作js大全
- jsJS时间戳与日期格式互相转换的简单方法示例js大全
- js代码JavaScript快速调试的两个技巧