在使用vue做后台管理的系统的时候,会有批量删除的操作,但是在找了很多资料之后仍然无法解决,希望得到大家的帮助。
axios({
method: 'delete',
url: that.baseURL,
params: {
id: [1,2]
},
headers: {'Content-Type': 'application/json'},
responseType: 'json'
}).then(function (response) {
console.log(response)
}).catch((error) => console.log(error))
当URL设置为thatbaseURL/id时是可以删除数据的,设置params为id:1也是无法删除数据的,会报如下错,是delete不支持设置params吗?
附server.js部分配置:
server.use(jsonserver.rewriter({
'/api/': '/',
'/api/users': '/users',
'/api/users/:id': '/users/:id',
'/api/users\\?id=:id': '/users/:id'
}))
如果大家发现什么错误,或者有什么建议,希望可以予以指点!
/api/users\\?id=:id
改成/api/users?id=:id
试试