【问题标题】:how to add multiple parameter in axios vue js如何在axios vue js中添加多个参数
【发布时间】:2019-05-24 16:16:03
【问题描述】:

我想在我的 axios 帖子中添加多个参数。我该怎么做?

我在这里尝试

axios.post('/select-files', this.$data.single, formData, config)
                    .then((response) => {
                        alert('Data Single Successfull Inserted.')
                        console.log(response);
                    })

我当前的代码只返回来自this.$data.single 的数据。

如果我像 formData, this.$data.single, config 这样更改代码,那么我的代码将只返回来自 formData 的数据

formdata 是返回这个数据

formData.append('image', this.image);

this.$data.single返回此数据

data() {
            return {
                files: [],
                errors: [],
                artistname: [],
                single: {},
                image: '',
                success: '',
                artist: [],
                showinput: [],
                searchText: '',
                items: [],
                lastSelectItem: {}
            }
        },

config

const config = {
                    headers: { 'content-type': 'multipart/form-data' }
                }

这不是我的完整代码。

【问题讨论】:

    标签: php laravel vue.js vuejs2


    【解决方案1】:

    你可以试试这个

       axios.post('/echo/json/', 'name='+this.name+'&pwd='+this.password, {headers: {
      'Content-type': 'application/x-www-form-urlencoded',
    }}).then(r => console.log('r: ', JSON.stringify(r, null, 2)));
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2020-09-16
      • 2020-05-13
      • 2018-09-16
      • 2020-04-21
      • 2020-04-03
      • 2018-07-21
      • 1970-01-01
      相关资源
      最近更新 更多