把文档还有github里的事例都试了一遍:一直报错:controller/hello not found;index.js文件编译后的没法读;
// 1、index.js
const { Router } = require('uni-cloud-router');
const router = new Router(require("./config/config.js"));
exports.main = async (event, context) => {
console.log(JSON.stringify(event))
return router.serve(event, context)
};
//2、Controller/hello.js
const { Controller } = require("uni-cloud-router");
module.exports = class HelloController extends (
Controller
) {
sayHello() {
return this.service.hello.sayHello();
}
};
//3、Service /hello.js
const { Service } = require("uni-cloud-router");
module.exports = class HelloService extends (
Service
) {
sayHello() {
return {
data: "welcome to uni-cloud-router!",
};
}
};
参数:
{
"action": "hello/sayHello",
"username": "username",
"password": "password"
}
本地云函数运行:controller/hello not found;
Joyce80 (作者)
很抱歉,完全是写法问题
2020-12-28 10:11