egg
egg
egg下载
npm init egg --type=simple
npm i
下载后启动
npm run dev
插件下载
下载
npm i 插件名
在config里面引入和配置,比如我们下载egg-cors解决跨域问题
//1.下载
cnpm i --save egg-cors
//2.开启插件
// config/plugin.js文件
cors:{
enable: true,
package: 'egg-cors',
}
//3.配置插件
// config/config.default.js文件
config.cors = {
origin: '*',
allowMethods: 'GET,HEAD,PUT,POST,DELETE,PATCH'
}
浙公网安备 33010602011771号