最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

如何访问使用快递JS app.set()设置变量

运维笔记admin21浏览0评论

如何访问使用快递JS app.set()设置变量

如何访问使用快递JS app.set()设置变量

如何访问变量设置使用快递的app.set()为e.g


app.set('view engine','jade');
app.set('jsDirectory',/js/');

从导,我知道我可以访问使用app.get(<key>)相同,但这是console.log(app.get('view engine'))的输出。

{ router:
   { app:
      { stack: [Object],
        domain: null,
        _events: [Object],
        _maxListeners: 10,
        _connections: 0,
        connections: [Getter/Setter],
        allowHalfOpen: true,
        _handle: null,
        httpAllowHalfOpen: false,
        cache: {},
        settings: [Object],
        redirects: {},
        isCallbacks: {},
        _locals: [Object],
        dynamicViewHelpers: {},
        errorHandlers: [],
        route: '/',
        routes: [Circular],
        router: [Getter],
        root: 'C:\\Users\\Shahal\\Works\\App',
        models: {},
        extensions: {},
        disconnectSchemas: [Function: disconnectSchemas],
        passport: [Object] },
     routes: {},
     params: {},
     _params: [],
     middleware: [Function] } }
回答如下:

通过app.settings反对他们变得可用:

app.set('oneSetting', 'one');
app.set('twoSetting', 'two');
app.set('view engine','jade');

console.log(app.settings.oneSetting);
console.log(app.settings.twoSetting);
console.log(app.settings['view engine']);
发布评论

评论列表(0)

  1. 暂无评论