在ElementUI+Express项目开发中,上传图片碰到了这样的问题:
1、首先,ElementUI代码如下:
<el-upload action="http://localhost/goods/addNewGoodsPicture" :limit="1" :onError="uploadError" :onSuccess="uploadSuccess" list-type="picture">
<el-button size="small" type="primary">点击上传</el-button>
</el-upload>
2、然后,我后台想尝试获取它传递的数据:
router.post("/addNewGoodsPicture", function (req, res, next) {
let newGoodsPicture = req.body.picture;
console.log("newGoodsPicture"+newGoodsPicture);
console.log("req:"+req);
})
3、结果,它给我报了个错误:
OPTIONS http://localhost/goods/addNewGoodsPicture net::ERR_CONNECTION_REFUSED
最后,想问下,有没有做过ElementUI+Express上传图片的同学,很想知道这要怎么去弄,因为我百度实在查不到相关资料了,所以想在SF提问一下有没有碰到相关问题的同学,谢谢!
你这个是前后端分离开发的吧,存在跨域,你百度一下cors,然后再express里面