We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
router 路由设置
router.resources('qrcode', '/api/qrcode', controller.qrcode);
controller 控制器设置
`'use strict';
const Controller = require('egg').Controller;
class QrcodeController extends Controller { async index() { const { ctx } = this; const { page } = ctx.request.query; ctx.boyd = '这里可以使用'; } async destroy() { const { ctx } = this; ctx.body = 1; } }
module.exports = QrcodeController; `
我在前台使用这个路由的时候 通过get 可以访问到 index 通过 DELETE 访问不到 destroy 如果将路由改为 router.del('qrcode', '/api/qrcode', controller.qrcode.destroy); 可以访问,有点搞不清楚问题在哪,好像put也有这个问题,有人能告诉我哪里错了吗?
router.del('qrcode', '/api/qrcode', controller.qrcode.destroy);
具体的 router.resources 的使用文档看这里:https://eggjs.org/zh-cn/basics/router.html#restful-%E9%A3%8E%E6%A0%BC%E7%9A%84-url-%E5%AE%9A%E4%B9%89
我确定已经参考文档使用了但还是存在问题 路由设置
控制器设置
postman请求结果
但是同路由下的index可以访问
The text was updated successfully, but these errors were encountered:
Delete 后面要带 id
Sorry, something went wrong.
Hello @yioMe. Please provide a reproducible example following the instruction.
Issues labeled by Need Reproduce will be closed if no activities in 7 days.
Need Reproduce
@yioMe,请根据这个说明提供最小可复现代码。
如果在 7 天内没有进展会被自动关闭。
@yioMe 要这么调 DELETE: api/qrcode/1 id 不是写在 body 里的,是写在 url 上
api/qrcode/1
No branches or pull requests
router 路由设置
router.resources('qrcode', '/api/qrcode', controller.qrcode);
controller 控制器设置
`'use strict';
const Controller = require('egg').Controller;
class QrcodeController extends Controller {
async index() {
const { ctx } = this;
const { page } = ctx.request.query;
ctx.boyd = '这里可以使用';
}
async destroy() {
const { ctx } = this;
ctx.body = 1;
}
}
module.exports = QrcodeController;
`
我在前台使用这个路由的时候
通过get 可以访问到 index
通过 DELETE 访问不到 destroy
如果将路由改为
router.del('qrcode', '/api/qrcode', controller.qrcode.destroy);
可以访问,有点搞不清楚问题在哪,好像put也有这个问题,有人能告诉我哪里错了吗?
我确定已经参考文档使用了但还是存在问题
路由设置
控制器设置
postman请求结果
但是同路由下的index可以访问
The text was updated successfully, but these errors were encountered: