dongqu9917 2018-12-26 11:23
浏览 153

如何在axios vue js中添加多个参数

i want to add multiple parameter in my axios post. how i can do it?

here what i try

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

my current code only return data from this.$data.single.

if i change code like this formData, this.$data.single, config, then my code will only return data from formData

formdata is return this data

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

this.$data.single return this data

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

and config is

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

this is not my full code.

  • 写回答

1条回答 默认 最新

  • dqde43215 2018-12-26 12:09
    关注

    You could try this

       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)));
    
    评论

报告相同问题?

悬赏问题

  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 保护模式-系统加载-段寄存器