大神的意思,是不是后端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