• 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>

  • 相关阅读:
    、你对测试最大的兴趣在哪里?为什么?
    软件配置管理的作用?软件配置包括什么?
    什么是软件测试?软件测试的目的与原则
    生命周期阶段:
    白盒测试的优点有:
    黑盒测试的缺点有:
    什么是软件质量?
    软件配置管理的作用?软件配置包括什么?
    什么是测试用例 什么是测试脚本 两者的关系是什么?
    软件的安全性应从哪几个方面去测试?
  • 原文地址:https://www.cnblogs.com/xiao-peng-ji/p/11335963.html
Copyright © 2020-2023  润新知