【问题标题】:Sending URL Query String through Vue / Axios通过 Vue / Axios 发送 URL 查询字符串
【发布时间】:2018-12-12 18:35:26
【问题描述】:

我对 Vue / Axios 还是很陌生。

我正在尝试使用 Axios 将查询字符串发送到电子邮件。查询字符串是从 Google Adwords 设置的。

http://website.co.uk/page.php?keyword=jh%20page&gclid=XXIaIZobFhEInb6zoDyH3AIViwDTCh1yawIPFYTAYASRAEgIJH_D_BwE

我目前的vue代码

const app = new Vue({
    el: '#app',
    data() {
        return {
            step: 1,
            counter: 0,
            tagName: null,
            debt: {
                name: null,
                email: null,
                tel: null
            }
        }
    },
    methods: {
        prev() {
            this.step--;
        },
        next() {
            this.step++;
        },
        submit() {
            axios.post('post.php', {
                'name': this.debt.name,
                'email': this.debt.email,
                'tel': this.debt.tel
            }).then(response => {
                console.log('success', response.data.message)
            }).catch(error => {
                console.log(error.response)
            });
        }
    }
});

希望有人能帮助我朝着正确的方向前进。如果您需要任何其他信息,请告诉我。

谢谢,J。

【问题讨论】:

  • 你遇到了什么错误?
  • 为什么不只发送姓名、电子邮件、电话、查询字符串

标签: vue.js vuejs2 axios


【解决方案1】:

如果您询问如何使用 axios 设置查询字符串,它在 request config 中设置为参数。

axios.request('/post.php', {
  method: 'post',
  params: {
    test: '321',
  },
});

【讨论】:

  • 谢谢,我想做的是从 URL 获取查询字符串,然后使用 Axios 将其发送到电子邮件。你知道我会怎么做吗?
  • 解析查询字符串有多种方式,一种是使用URLSearchParams
猜你喜欢
  • 2021-10-05
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2022-01-19
  • 1970-01-01
  • 2014-06-29
  • 1970-01-01
相关资源
最近更新 更多