zoukankan      html  css  js  c++  java
  • 路由之编程导航

    <template>
      <div class="home">
        <button @click="handleClick('back')">返回上一页</button>
        <button @click="handleClick('push')">跳转到parent</button>
        <button @click="handleClick('replace')">替换到parent</button>
      </div>
    </template>
    
    <script>
    // @ is an alias to /src
    import HelloWorld from '@/components/HelloWorld.vue'
    
    export default {
      name: 'home',
      components: {
        HelloWorld
      },
      methods:{
        handleClick(type){
          if (type==="back") {
            //this.$router.back();
            this.$router.go(-1);
          }else if (type==="push") {
            const name="caoqi";
            //使用push会在浏览器中加入一个记录
            //使用路径跳转
            //this.$router.push("/parent");
            //还可以使用命名路由的方式:
            this.$router.push({
              // name: "parent",
              // //加入name参数,http://localhost:8080/#/parent?name=caoqi
              // query: {
              //   name: 'caoqi'
              // }
    
              // name: "argu",
              // //加入name参数,http://localhost:8080/#/argu/caoqi
              // params: {
              //   name: 'caoqi'
              // }
    
    
              //ES6写法:
              path:`/argu/${name}`,
            })
          }else if (type==="replace") {
            //使用replace不会在浏览历史中加入记录
            this.$router.replace({
              name: 'parent'
            })
          }
        }
      }
    }
    </script>

  • 相关阅读:
    jQuery插件之artDialog
    jQuery插件之ajaxFileUpload
    jQuery插件之Cookie
    jQuery插件之Form
    jQuery与DOM对象的转换
    jQuery之AJAX
    jQuery之元素筛选
    jQuery之位置
    POJ2096 概率dp 入门
    Sichuan State Programming Contest 2012 C。Counting Pair
  • 原文地址:https://www.cnblogs.com/qicao/p/10778831.html
Copyright © 2011-2022 走看看