zoukankan      html  css  js  c++  java
  • 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

    后续研究#号的问题

     
  • 相关阅读:
    IoC和AoP
    学习树
    Avalon Framework概念
    java利用WatchService实时监控某个目录下的文件变化并按行解析
    [DBT-08001] 无法检查可用内存。
    C#之http协议与soap协议之间的区别
    C#之ActionResult 详解
    C#实现连接池
    C#MVC之传入字典的模型项为 null,但此字典需要类型“System.Decimal”的非 null 模型项。
    Func的介绍
  • 原文地址:https://www.cnblogs.com/silences/p/6733336.html
Copyright © 2011-2022 走看看