zoukankan      html  css  js  c++  java
  • vue main.js 配置 路由

    // The Vue build version to load with the `import` command
    // (runtime-only or standalone) has been set in webpack.base.conf with an alias.
    import Vue from 'vue';
    import VueRouter from 'vue-router';
    import App from './App';
    import goods from './components/goods/goods';
    import ratings from './components/ratings/ratings';
    import seller from './components/seller/seller';
    
    /* 安装vue-router插件 */
    Vue.use(VueRouter); // 注册路由
    
    /* 定义路由页面 */
    const routes = [
        // 这里 path: '/' 代表应用首页显示的内容
        { path: '/goods', component: goods },
        { path: '/ratings', component: ratings },
        { path: '/seller', component: seller }
    ];
    
    const router = new VueRouter({
        // mode指定路由模式,默认'hash',另一种可选的模式是'history'
        mode: 'history',
        routes
    });
    
    /* 创建挂载点至#app元素,将内容显示在index.html页面 */
    let app = new Vue({
        el: '#app',
        router,
        render: h => h(App)
    });
    
    Vue.use({
        app
    });
  • 相关阅读:
    python3中的线程简记
    python3中的SMTP简记
    sql依赖注入简记
    python Internet模块
    python-socket编程简例
    1.docker简介及安装
    kvm迁移
    kvm网络管理
    kvm存储池和存储卷
    2.标准数据类型--字符串
  • 原文地址:https://www.cnblogs.com/xzma/p/7727642.html
Copyright © 2011-2022 走看看