問題描述我在前臺頁面使用jq傳值時傳了數(shù)組,后端console.log(req.body)也能看到數(shù)組的數(shù)據(jù),但是賦值接收卻是undefined;我想問問后端怎么才能成功賦值接收到傳來的數(shù)組問題出現(xiàn)的環(huán)境背景及自己嘗試過哪些方法相關(guān)代碼//請把代碼文本粘貼到下方(請勿用圖片代替代碼)前端請求代碼:$("#getData").click(function(){console.log("點擊事件");$.ajax({type:'post',url:'/getArrData',data:{userName:'jack',arr:["蘋果","香蕉"]},success:(data)=>{console.log("成功的回調(diào)",data);},error:(error)=>{console.log("失敗的回調(diào)",error);}})})后端接收代碼:getArrData:(req,res)=>{letuserName=req.body.userName;letarr=req.body.arr;console.log('userName:',userName);console.log('arr',arr);console.log(req.body);res.send("成功")}console的結(jié)果:userName:jackarrundefined[Object:nullprototype]{userName:'jack','arr[]':['蘋果','香蕉']}你期待的結(jié)果是什么?實際看到的錯誤信息又是什么?我想arr能接收到req.body的數(shù)組;也就是能接收到前端傳過來的數(shù)組
萌新!nodejs 如何接收前臺穿過來的數(shù)組
Qyouu
2019-08-17 10:06:57