大神的意思,是不是後端php就不好寫,重新換思路,改掉前端,還是怎樣?下面是程式碼請幫忙看一下,萬分感謝@!
【前端大致簡單的程式碼】如下:
1:this.selectedList.push({ good_id:this.cartList[index].goodid,
num:this.cartList[index].sp_shuliang,good_jiage:this.cartList[index].sp_jiage });
2:var canshu={good_xinxi:JSON.stringify(there.selectedList) };
await this.axios({
method: 'POST',
url: '/php_api/wxpay/gwche_Dopay.php?ask=Doshouyin',
data:canshu
}).then(res => {
console.log(res); })
////////////////////////////////////////////////// ////////////////////////////////////////////////// ////////////
【後端PHP】嘗試過的方法:
1: $aa=$_POST['good_xinxi'];
foreach( (array)$aa as $v){
echo $v['good_id']}
////////////////////////////////////////////////// /////////////////////
2: $aa=$_POST['good_xinxi'];
$bb=array_column( (array)$aa,'good_id')
echo $bb;
////////////////////////////////////////////////// ////////////////////
3: $aa=$_POST['good_xinxi'];
foreach( (array)$aa as $v){
echo $v->good_id; }
////////////////////////////////////////////////// //////////////////////////
【以上方法全都不行】
嘗試過列印: var_dump($_POST['good_xinxi']);【 結果沒問題】如下:
data: "string(87) "[{"good_id":276,"num":1,"good_jiage":"0.3"},{"good_id":277,"num":1,"good_jiage":"0.1 "}]"↵"
errMsg: "request:ok"
header: {Server: "nginx/1.15.11", Date: "Wed, 27 Jan 2021 10:09:27 GMT", Content-Type: "application/json", Transfer-Encoding: "chunked", Connection: " keep-alive", …}
statusCode: 200
__proto__: Object