egg-dict
v1.0.1
Published
egg data dictionary plugin
Downloads
1
Maintainers
Readme
Install
$ npm i --save egg-dict
Usage & configuration
config.default.js
// 相对app目录的路径
exports.dict = {
path: 'dict'
};
config/plugin.js
exports.dict = {
enable: true,
package: 'egg-dict'
}
example
// app/dict/demo/demo.js
module.exports = {
status: {
error: '错误',
success: '成功'
}
}
// controller.js or service.js
console.log(this.ctx.dict.demo.demo.status);
//print: {error: "错误", success: "成功"}
// app/dict/demo/demo.js
// 只为了说明可以使用app
module.exports = (app)=>{
return {
statusWithApp: {
appPath: app.baseDir
}
}
}
// controller.js or service.js
console.log(this.ctx.dict.demo.demo.statusWithApp.appPath);
//print: /path/to/app-basedir