首页 > 编程知识 正文

vue页面获取url参数,vue 获取url地址的参数

时间:2023-05-06 09:05:15 阅读:283504 作者:4347

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

版权声明:该文观点仅代表作者本人。处理文章:请发送邮件至 三1五14八八95#扣扣.com 举报,一经查实,本站将立刻删除。