Express.js – app.disabled() 方法
**app.disabled()** 方法檢查並返回 true,如果傳遞的 property 名稱設定為 False 或已被停用。如果未停用,則可以使用 **app.disable()** 方法停用該 property。
語法
app.disabled( name )
示例 1
建立一個名為 "appDisabled.js" 的檔案,並複製以下程式碼片段。建立檔案後,使用以下示例中所示的命令 "node appDisabled.js" 執行此程式碼 −
// app.disabled() Method Demo Example
// Importing the express module
const express = require('express');
// Initializing the express and port number
var app = express();
// Initializing the router from express
var router = express.Router();
var PORT = 3000;
// Checking the foo property
console.log("Is Settings disabled: ", app.disabled('trust proxy'));輸出
C:\home
ode>> node appDisabled.js Is Settings disabled: true
示例 2
我們來看另一個示例。
// app.disabled() Method Demo Example
// Importing the express module
const express = require('express');
// Initializing the express and port number
var app = express();
// Initializing the router from express
var router = express.Router();
var PORT = 3000;
app.enable('trust proxy');
// Checking the foo property
console.log("Is Settings disabled: ", app.disabled('trust proxy'));輸出
C:\home
ode>> node appDisabled.js Is Settings disabled: false
廣告
資料結構
網路
關係型資料庫管理系統
作業系統
Java
iOS
HTML
CSS
Android
Python
C 程式設計
C++
C#
MongoDB
MySQL
Javascript
PHP