• vuerouter-5.参数传递


    App.vue-------------------------------------------------------------------------------------------------

    <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> -->
    <router-link :to="{name:'HelloWorld',params:{id:helloparams}}" tag="li">HelloWorld</router-link>
    <router-link :to="{name:'learn'}" tag="li">learn</router-link>
    </ul>
    <button class="btn" @click="gotoHello">去learns</button>
    <router-view />
    </div>
    </template>

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

    },
    data(){
    return{
    helloparams:"hellodemo",
    clickParams:"hahaha"
    }
    },
    methods: {
    gotoHello() {
    //this.$router.push("/h")
    //this.$router.replace("/h")
    //this.$router.go(-1)
    this.$router.push({name:"learn",params:{id:this.clickParams}})
    }
    }
    }
    </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;
    }

    .btn {
    border: 1px solid #fff;
    padding: 5px;
    color: #fff;
    background-color: #0000FF;
    cursor: pointer;
    }
    </style>

    2.实例-----------------------------------------------------------------

    <template>
    <div class="hello">
    <h1>{{ msg }}</h1>
    <h2>Essential Links</h2>
    <h3>{{this.$route.params.id}}</h3>
    <ul>
    <li>
    <a
    href="https://vuejs.org"
    target="_blank"
    >
    Core Docs
    </a>
    </li>
    <li>
    <a
    href="https://forum.vuejs.org"
    target="_blank"
    >
    Forum
    </a>
    </li>
    <li>
    <a
    href="https://chat.vuejs.org"
    target="_blank"
    >
    Community Chat
    </a>
    </li>
    <li>
    <a
    href="https://twitter.com/vuejs"
    target="_blank"
    >
    Twitter
    </a>
    </li>
    <br>
    <li>
    <a
    href="http://vuejs-templates.github.io/webpack/"
    target="_blank"
    >
    Docs for This Template
    </a>
    </li>
    </ul>
    <h2>Ecosystem</h2>
    <ul>
    <li>
    <a
    href="http://router.vuejs.org/"
    target="_blank"
    >
    vue-router
    </a>
    </li>
    <li>
    <a
    href="http://vuex.vuejs.org/"
    target="_blank"
    >
    vuex
    </a>
    </li>
    <li>
    <a
    href="http://vue-loader.vuejs.org/"
    target="_blank"
    >
    vue-loader
    </a>
    </li>
    <li>
    <a
    href="https://github.com/vuejs/awesome-vue"
    target="_blank"
    >
    awesome-vue
    </a>
    </li>
    </ul>
    </div>
    </template>

    <script>
    export default {
    name: 'HelloWorld',
    data () {
    return {
    msg: 'Welcome to Your Vue.js App'
    }
    }
    }
    </script>

    <!-- Add "scoped" attribute to limit CSS to this component only -->
    <style scoped>
    h1, h2 {
    font-weight: normal;
    }
    ul {
    list-style-type: none;
    padding: 0;
    }
    li {
    display: inline-block;
    margin: 0 10px;
    }
    a {
    color: #42b983;
    }
    </style>

  • 相关阅读:
    linux kill命令以及 信号
    rhel7 系统服务——unit(单元)
    redis集群在线迁移
    二、主目录 Makefile 分析(3)
    二、主目录 Makefile 分析(2)
    二、主目录 Makefile 分析(1)
    一、文档目录分析
    Linux下解压缩
    设备树
    轮询
  • 原文地址:https://www.cnblogs.com/xiao-peng-ji/p/11336814.html
Copyright © 2020-2023  润新知