vue 获取url后面的参数

1   获取?后面的参数

      http://192.168.1.105:8080/#/idInput?username=%22%E5%BC%A0%E4%B8%89%22

     获取参数方法     let id = this.$route.query.username

2 获取不带?的URL中的参数

      http://192.168.1.12:8080/#/home/newsinfo/234

    在路由中配置路由

    { path: '/home/newsinfo/:id', component: Newsinfo }

     .vue页面设置

    <template>

          <router-link :to="'/home/newsinfo/' + item.id">

    </template>

     获取参数方法    let id = this.$route.params.id

posted @ 2020-08-19 13:56  leahtao  阅读(25672)  评论(0编辑  收藏  举报