vue管理系统笔记

1.lintfix  npm run lintfix 自动修复代码规范

2.在packjage.json中

"scripts": {
    "dev": "webpack-dev-server --inline --progress --config build/webpack.dev.conf.js --open",//加上--open 自动打开浏览器
    "start": "npm run dev",
    "unit": "jest --config test/unit/jest.conf.js --coverage",
    "e2e": "node test/e2e/runner.js",
    "test": "npm run unit && npm run e2e",
    "build": "node build/build.js"
  },

2.  路由跳转  搜索框的路由连接不存在让它跳主页面

{path:'*',redirect:'/'}

5.导航守卫

路由跳转前做一些验证,比如登录验证,是网站中的普遍需求。

对此,vue-route 提供的 beforeRouteUpdate 可以方便地实现导航守卫(navigation-guards)。

在全局的Main.js中注册:router,如果有的话就可以直接调用

router.beforeEach((to, from, next) => {
 

  if(to.path == '/login' || to.path == '/register'){
    next()
  }else{
    alert('你还没有登录!')
  next('/login')
  }
})

6.router-view 的复用

7.routerscroll

猜你喜欢

转载自blog.csdn.net/weixin_42312074/article/details/90812639