• vue 学习笔记


    今天研究了vux的demo

    https://github.com/jinhuiWong/vux-2.0

    将main.js中的路由文件提取到router/index.js中

    整合代码

    import router from './router/index.js'
    import VueRouter from 'vue-router'
    Vue.use(VueRouter)
    import router from './router/index.js'
    引入时候出现了错误是因为下面定义了const router ,注释了之后生效
    将注释代码整合到router/index.js中
    import VueRouter from 'vue-router'
    
    // var rootPath=config.build.assetsPublicPath;
    var rootPath = "/";
    
    
    /** -------------------------------------------------- 懒加载start --------------------------------------------*/
    
    const Home = resolve => require(['../components/HelloFromVux.vue'], resolve)
    const Demo = resolve => require(['../components/Hello.vue'], resolve)
    
    /** -------------------------------------------------- 懒加载end --------------------------------------------*/
    const router = new VueRouter({
      mode: 'hash',
      base: __dirname,
      //路由映射map
      routes: [
        {path: rootPath, component: Home, meta: {scrollToTop: true}, name: 'home'},
        { path: rootPath + 'demo', component: Demo , name: 'demo'},
    
        //找不到页面就返回404页面
        {
          path: '*',
          component: {template: '<p style="height:300px;text-align:center">404</p>'}
        }
      ]
    });
    
    
    export default router

    访问localhost:8080时候home生效

    访问:http://localhost:8080/demo

    不生效

    原因:要在demo前面加#,正确的访问方法http://localhost:8080/#/demo

    后续研究#号的问题

     
  • 相关阅读:
    杭电2063 过山车 匈牙利算法
    杭电2023 平均成绩
    leveldb性能分析
    linux下libreoffice安装测试
    iptables配置vsftp访问
    vsftp访问异常
    mysql二进制安装
    vi命令
    mysql配置优化
    rsync 配置
  • 原文地址:https://www.cnblogs.com/silences/p/6733336.html
Copyright © 2020-2023  润新知