zoukankan      html  css  js  c++  java
  • vue 带参数的跳转-完成一个功能之后 之后需要深思,否则还会忘记

    我要写详细点,否则下次很容易忘记

    写了一个页面,这个页面里面添加了 很多a 标签,跳转都是同一个页面,内容不一样,方法

    首先 路由 设定好 routes:[

      {
        path:'/aaa',

        name:'A',

        component:HelloWorld
      }

    ]

    跳转的那个页面  a标签 写好 跳转  我用了一个跳转的事件  @click = handleClick('1'),@click = handleClick('2');

    并且每个不同页面 引入了 不同的参数

    methods:{

      handleClick:function(type){
        this.$router.push('/aaa?type='+type);
      }

    }

    跳转的那个组件页面 可以用query 去接这个type的值

    <template>

      <div>

        <p v-show="this.dataType === ‘1’ ">我是type 为1</p>

        <p v-show="this.dataType === '2' ">我是type 为2</p>

      </div>

    </template> 

    data(){

      return {

        typeData :''

      }

    }

    mounted:function(){
      this.getPage();
    }

    methods:{
      getPage:function(){

        this.typeData = this.$route.query.type

      }
    }

    因为公司电脑有限制,在自己电脑才能写博客,故没有截图,潦草了些,完成一个功能之后 之后需要深思,否则还会忘记。

    感谢青云,让我在写代码的这个世界里越来越快乐

  • 相关阅读:
    【蓝桥杯训练】第二天1261
    【蓝桥杯训练】第二天1259、1260
    【蓝桥杯训练】第二天1255、1258
    【蓝桥杯训练】第一天1252
    【蓝桥杯训练】第一天1253
    【蓝桥杯训练】第一天1251
    【蓝桥杯训练】第一天1250
    Map,reduce,zip,dir 简化你的操作
    C# await和async
    python 入门笔记
  • 原文地址:https://www.cnblogs.com/qingcui277/p/8776777.html
Copyright © 2011-2022 走看看