zoukankan      html  css  js  c++  java
  • vuerouter-2.路由跳转

    1.单独的设置路由的index.js

    -------------------------------------------------------------------------------------

    import Vue from 'vue'
    import VueRouter from 'vue-router'
    //@表示寻找根目录
    import HelloWorld from '@/components/HelloWorld'
    import learn from '@/components/learn'
    Vue.use(VueRouter)
    //创建路由
    export default new VueRouter({
    routes:[
    {
    path:"/h",
    name:"HelloWorld", //可以作为跳转使用
    component:HelloWorld
    },
    {
    path:"/learn",
    name:"learn",
    component:learn
    }
    ]
    })

    --------------------------------------------------------------------------------------------------------------------

    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 App from './App'
    import router from './router'
    Vue.config.productionTip = false

    /* eslint-disable no-new */
    new Vue({
    el: '#app',
    router,
    components: { App },
    template: '<App/>'
    })

    实例---------------------------------------------------------------------------------------------------------------

    <template>
    <div id="app">
    <img src="./assets/logo.png">
    <ul>
    <router-link to="/h" tag="li">HelloWorld</router-link>
    <router-link to="/learn" tag="li">learn</router-link>
    </ul>
    <router-view />
    </div>
    </template>

    <script>
    export default {
    name: 'App',
    components: {

    }
    }
    </script>

    <style>
    #app {
    font-family: 'Avenir', Helvetica, Arial, sans-serif;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-align: center;
    color: #2c3e50;
    margin-top: 60px;
    }

    ul li {
    text-align: center;
    display: inline-block;
    text-decoration: underline;
    cursor: pointer;
    color: blue;
    }

    ul li+li {
    margin-left: 20px;
    }
    </style>

  • 相关阅读:
    【cocos2d-x 024】 LINK : fatal error LNK1123: 转换到 COFF 期间失败: 文件无效或损坏
    【cocos2d-x 024】 LINK : fatal error LNK1123: 转换到 COFF 期间失败: 文件无效或损坏
    socket 通信代码,单线程
    socket 通信代码,单线程
    socket 通信代码,单线程
    使用Cocos Studio 创建帧动画
    使用Cocos Studio 创建帧动画
    使用Cocos Studio 创建帧动画
    sscanf函数用法详解
    (OK) firefox
  • 原文地址:https://www.cnblogs.com/xiao-peng-ji/p/11335963.html
Copyright © 2011-2022 走看看