search

Home  >  Q&A  >  body text

javascript - How to pass parameters to the get method in vue-resource without using splicing.

When I used the get method before, I always subconsciously spliced ​​the parameters on the link. Recently I heard that when using the get method of vue-resource, I can directly pass the parameters like a post. I couldn't find the document address and wanted to take a leave directly. Now, how should this parameter be passed?

The following method I used does not work~
let arg = {search: 'haha'}
this.$http.get(link, arg, {

...

}

学习ing学习ing2724 days ago907

reply all(1)I'll reply

  • 女神的闺蜜爱上我

    女神的闺蜜爱上我2017-06-15 09:25:35

         getInfo(){
            const params = {partnerId: partnerId, openId: openId}
            this.$http.get(commonUrl + "/restful/member2?op=get", {params:params}).then(response => {
                console.log(response)
              if (response.data.errcode === 0) {
                this.dataInfo = response.data
              } else {
    //            this.$router.push({path: '/Register'})
              }
              Indicator.close()
            }, response => {
            });
          },
    

    Like this. . . For reference only

    Now vue is more recommended to use axios

    axios.get('/user', {
        params: {
          ID: 12345
        }
      })
      .then(function (response) {
        console.log(response);
      })
      .catch(function (error) {
        console.log(error);
      });
    

    This should be what you want~

    reply
    0
  • Cancelreply