vue.js如何带参数跳转


当前第2页 返回上一页

1

2

this.$route.params.参数名

this.$route.query.参数名

实验(包含两种方式):

传递页:

1

2

3

4

5

6

7

8

9

<router-link :to="{ name: 'readDetail', params: { msgKeyOne: 'jump test.' }}">

               <button type="button">跳转</button>

             </router-link><button @click="sendParams">传递</button>-----------------------------------------------------------------------------------------export default {

   name: 'reads',

   data () {

     return {

       msg: 'msg test.'

     }

   },

接收页:

1

2

3

4

5

6

7

8

9

10

11

12

<div class="container">

    <p style="color:red;">Num:{{ myIndex }}</p>

    <p>{{ msg }}</p>

  </div>-----------------------------------------------------------data () {

      return {

        msg: '',

        // 保存传递过来的index

        myIndex: ''

      }-----------------------------------------------------------mounted: function () {

      this.msg = this.$route.params.msgKeyOne      this.myIndex = this.$route.params.msgKey

      console.log(this.myIndex)

    }

相关免费学习推荐:javascript(视频)

以上就是vue.js如何带参数跳转的详细内容,更多文章请关注木庄网络博客

返回前面的内容

相关阅读 >>

深入研究vue cli3

vue.js的优势是什么

vue.js开发环境怎么搭建

vue.js插槽有什么用

如何做到刷新vue.js改变数据

vue.js怎么改变样式

使用vue.js怎么定义全局变量

vue.js如何创建项目

vue.js怎么获取class

浅谈vue.js中的props(单向数据流)

更多相关阅读请进入《vue.js》频道 >>




打赏

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码打赏,您说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

分享从这里开始,精彩与您同在

评论

管理员已关闭评论功能...