温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

vue 2.8.2版本如何配置默认页面

发布时间:2021-08-18 14:43:48 来源:亿速云 阅读:115 作者:小新 栏目:web开发

这篇文章主要为大家展示了“vue 2.8.2版本如何配置默认页面”,内容简而易懂,条理清晰,希望能够帮助大家解决疑惑,下面让小编带领大家一起研究并学习一下“vue 2.8.2版本如何配置默认页面”这篇文章吧。

vue --version查看版本 是 2.8.2;

vue 2.8.2版本配置刚进入时候的默认页面比如这里面的goods页面;

1.在路由文件下里面的index.js文件 添加 { path: '/', redirect: '/goods/goods' }, // 默认就跳转此页面

2.也可以在app.vue里面配置

this.$router.push('/goods/goods'); // 页面加载时跳转

详情看下面

export default {
 name: 'app',
 components: {
  'v-header': header
 },
 created () {
//  this.$router.push('/goods/goods'); // 页面加载时跳转
 }
 };

前提都配置了此组件路由index.js文件如下

import Vue from 'vue';
import Router from 'vue-router';
import goods from '../components/goods/goods';
import ratings from '../components/ratings/ratings';
import seller from '../components/seller/seller';

Vue.use(Router);

export default new Router({
 routes: [
 { path: '/', redirect: '/goods/goods' }, // 默认就跳转此页面
 {
  path: '/goods/goods',
  name: 'goods',
  component: goods
 },
 {
  path: '/ratings/ratings',
  name: 'ratings',
  component: ratings
 },
 {
  path: '/seller/seller',
  name: 'seller',
  component: seller
 }
 ]
});

以上是“vue 2.8.2版本如何配置默认页面”这篇文章的所有内容,感谢各位的阅读!相信大家都有了一定的了解,希望分享的内容对大家有所帮助,如果还想学习更多知识,欢迎关注亿速云行业资讯频道!

向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

vue
AI