Vue how to put the value of data, all one-time post to the background, and get it?

1. The value of the foreground data is as follows:

var vm = new Vue({
  el: "-sharpvm",
    data: {
        offer: {
            isshow:false,
            sum_total_price:0,
            sum_discount:0,
            sum_price:0,
            children:[
            {
              type_id:"1",
              type_name:"",
              title: "",
              date: "",
              price: 0,
              number:1,
              time:1,
              total_price:0,
              discount: 0,
              other: "",
            }, {
              type_id:"2",
              type_name:"",
              title: "",
              date: "",
              price: 0,
              number:1,
              time:1,
              total_price:0,
              discount: 0,
              other: "",
            }, {
              type_id:"3",
              type_name:"",
              title: "",
              date: "",
              price: 0,
              number:1,
              time:1,
              total_price:0,
              discount: 0,
              other: "",
            }, {
              type_id:"4",
              type_name:"",
              title: "",
              date: "",
              price: 0,
              number:1,
              time:1,
              total_price:0,
              discount: 0,
              other: "",
            }, {
              type_id:"5",
              type_name:"",
              title: "",
              date: "",
              price: 0,
              number:1,
              time:1,
              total_price:0,
              discount: 0,
              other: "",
            }, {
              type_id:"6",
              type_name:"",
              title: "",
              date: "",
              price: 0,
              number:1,
              time:1,
              total_price:0,
              discount: 0,
              other: "",
            }, {
              type_id:"7",
              type_name:"",
              title: "",
              date: "",
              price: 0,
              number:1,
              time:1,
              total_price:0,
              discount: 0,
              other: "",
            }, {
              type_id:"8",
              type_name:"",
              title: "",
              date: "",
              price: 0,
              number:1,
              time:1,
              total_price:0,
              discount: 0,
              other: "",
            }, {
              type_id:"9",
              type_name:"",
              title: "",
              date: "",
              price: 0,
              number:1,
              time:1,
              total_price:0,
              discount: 0,
              other: "",
            }, {
              type_id:"10",
              type_name:"",
              title: "",
              date: "",
              price: 0,
              number:1,
              time:1,
              total_price:0,
              discount: 0,
              other: "",
            }, {
              type_id:"11",
              type_name:"",
              title: "",
              date: "",
              price: 0,
              number:1,
              time:1,
              total_price:0,
              discount: 0,
              other: "",
            }, {
              type_id:"12",
              type_name:"",
              title: "",
              date: "",
              price: 0,
              number:1,
              time:1,
              total_price:0,
              discount: 0,
              other: "",
            }, {
              type_id:"13",
              type_name:"",
              title: "",
              date: "",
              price: 0,
              number:1,
              time:1,
              total_price:0,
              discount: 0,
              other: "",
            }, {
              type_id:"14",
              type_name:"",
              title: "",
              date: "",
              price: 0,
              number:1,
              time:1,
              total_price:0,
              discount: 0,
              other: "",
            }, {
              type_id:"15",
              type_name:"",
              title: "",
              date: "",
              price: 0,
              number:1,
              time:1,
              total_price:0,
              discount: 0,
              other: "",
            }
            ]
        },
        title:"",
        date:"2018-12-12",
        adult:"0",
        children:"0",
        gocity:"",
        tocity:"",
        special:"",
        tour:[
                {title:"",isshow:false,children:[
                    {title:"",type:1,other:"",children:[
                        {flight_number:"",flight_space:"1",start_time:"",start_airport:"",start_terminal:"",end_time:"",end_airport:"",end_terminal:"",stop_city:"",stop_hour:"",stop_minute:"",overnight:""},
                        {flight_number:"",flight_space:"1",start_time:"",start_airport:"",start_terminal:"",end_time:"",end_airport:"",end_terminal:"",stop_city:"",stop_hour:"",stop_minute:"",overnight:""}
                    ]},
                    {title:"",type:2,other:"",children:[
                        {sight_name:"",sight_id:"",img:""},
                        {sight_name:"",sight_id:"",img:""}
                    ]},
                    {title:"",type:3,other:"",children:[
                        {hotel_name:"",hotel_id:"",img:""},
                        {hotel_name:"",hotel_id:"",img:""}
                    ]},
                    {title:"",type:4,meal:1,other:"",children:[
                        {cater_name:"",cater_id:"",img:""},
                        {cater_name:"",cater_id:"",img:""}
                    ]},
                    {title:"",type:5,other:""},
                    {title:"",type:6,other:""}
                ]}
            ]
    }
})

2. The axios file is also introduced into the page:

<script src="https://unpkg.com/axios/dist/axios.min.js"></script>

3. The test submission code is as follows:

        axios.post("{:url("api/plan/save")}", {
             firstName: "Fred",
             lastName: "Flintstone"
        })
        .then(function (response) {
            console.log(response);
        })
        .catch(function (error) {
            console.log(error);
        });

4. The data is passed by post, with a status of 2000, but the backend php $_ POST cannot get the data from post. What do I need to do?
and how do you operate if you post all the values in data?

add:
added another Qs file

JS
<script src="https://unpkg.com/axios/dist/axios.min.js"></script>
<script src="https://cdn.bootcss.com/qs/6.5.2/qs.min.js"></script>

//post
    let postData={
        title:vm.title,
        date:vm.date,
        adult:vm.adult,
        children:vm.children,
        gocity:vm.gocity,
        tocity:vm.tocity
    }

    axios.post("{:url("api/plan/save")}",Qs.stringify(postData))
    .then(function (response) {
        console.log(response);
    })
    .catch(function (error) {
        console.log(error);
    });

//php$_POST
array (size=6)
  "title" => string "" (length=6)
  "date" => string "2018-12-12" (length=10)
  "adult" => string "0" (length=1)
  "children" => string "0" (length=1)
  "gocity" => string "" (length=6)
  "tocity" => string "" (length=6)

//chrome
array (size=6)
  "title" => string "" (length=6)
  "date" => string "2018-12-12" (length=10)
  "adult" => string "0" (length=1)
  "children" => string "0" (length=1)
  "gocity" => string "" (length=6)
  "tocity" => string "" (length=6)

in addition, how do you give the entire data value of vue to post like postData?
at present, you just correspond to the value of data, concatenate it to postData, and then post it.

Mar.31,2022

$_ POST can only receive data submitted by Content-Type: application/x-www-form-urlencoded

API post parameters are passed using file_get_contents ("php://input") to get


set content-type:'application/x-www-form-urlencoded'
pass the value with data: {}


vm.$data

Menu