Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
4.1k views
in Technique[技术] by (71.8m points)

js数据格式转换问题

现在我遇到这样一个问题

const handleSave = () => {
    request('abc.htm', {
      method: 'post',
      params: {
        productId: paramsObject.productId,
        ticketMainKindVid,
        params: atomicItems
      }
    }).then(data => {
      if (data.success) {
        message.success('保存成功')
      }
    })
  }

我的atomicItems格式是这样的

[
        {
            "ticketKindType":"Audit",
            "ticketKindDesc":"成人票",
            "ticketKindVid":456,
            "amount":2,
            "minAge":18,
            "maxAge":60
        },
        {
            "ticketKindType":"Child",
            "ticketKindDesc":"儿童票",
            "ticketKindVid":123,
            "amount":1,
            "minAge":3,
            "maxAge":8
        }
    ]

但是请求到服务端之后,在network变成了这样
image.png

问一下大家这是怎么回事,要怎么解决


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

看不到你怎么封装的请求 。 不过你把 params改成data试试
http://www.axios-js.com/zh-cn...

const handleSave = () => {
    request('abc.htm', {
      method: 'post',
      data: {
        productId: paramsObject.productId,
        ticketMainKindVid,
        params: atomicItems
      }
    }).then(data => {
      if (data.success) {
        message.success('保存成功')
      }
    })
  }

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...