Welcome to OStack Knowledge Sharing 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 Answer

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('保存成功')
      }
    })
  }

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...