• vueaxios中的delete data报错


    post 请求这样写正常请求:

    methods: {
          createnode(){
                //执行测试任务
                console.log('获取当前vue的所有数据:')
                console.log(this)
                var get_data = this.$data
                console.log(get_data)
    
                var vue_data_url = this.globalHttpUrl + ':8666/create_new_node'
                axios.post(vue_data_url, JSON.stringify(get_data),{
                    headers: {
                        'Content-Type': 'application/json'}
                    })
                .then(response =>{
            
                    console.log(response)
                    alert('创建成功,返回测试任务列表查看节点信息')
                }
                )
            }
        }
      }

    但是delete这样写请求异常了:

    methods: {
          createnode(){
                //执行测试任务
                console.log('获取当前vue的所有数据:')
                console.log(this)
                var get_data = this.$data
                console.log(get_data)
    
                var vue_data_url = this.globalHttpUrl + ':8666/create_new_node'
                axios.delete(vue_data_url, JSON.stringify(get_data),{
                    headers: {
                        'Content-Type': 'application/json'}
                    })
                .then(response =>{
            
                    console.log(response)
                    alert('创建成功,返回测试任务列表查看节点信息')
                }
                )
            }
        }
      }

    delete请求需要这样写:

     deletenodefun(){
                //执行测试任务
                console.log('获取当前vue的所有数据:')
                console.log(this)
                var get_data = this.$data
                console.log(get_data)
                console.log(JSON.stringify(get_data))
    
                var vue_data_url = this.globalHttpUrl + ':8666/delete_node'
                axios.delete(vue_data_url, {
                    headers:{'Content-Type': 'application/json'},
                    data:JSON.stringify(get_data)
                })
                .then(response =>{
                    console.log(response)
                    alert('删除成功请返回到“测试任务”页面查看')
                }
                )
            }
           
        }

    在axios官网也能看到一些信息:

  • 相关阅读:
    让他人变得优秀是伟大
    年龄越大,离家越远
    秋天的叶子
    [短彩信]C#短彩信模块开发设计(2)——配置
    jquery实现网页二级菜单简单代码
    HTML页面做中间页跳转传递参数
    ToJson
    Button页面中的按钮
    SQLSERVER 18056 错误
    在桌面添加可拖动/点击的悬浮窗口
  • 原文地址:https://www.cnblogs.com/tarzen213/p/16243406.html
Copyright © 2020-2023  润新知