Express.js - 應用程式停用()方法
應用程式停用()方法停用在此函式中傳入的設定名稱。此方法將設定名稱設定為 False。我們還可以使用應用程式.設定()方法透過將其值傳遞為 False 來執行相同的功能。
語法
app.disable(name)
示例 1
使用名稱"appDisable.js"建立一個檔案,並複製以下程式碼片段。建立檔案後,使用命令"節點應用程式停用.js"來執行此程式碼。
// app.disable() 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;
// Disabling the property foo
app.disable('foo');
// Checking the foo property
console.log(app.get('foo'));輸出
C:\home
ode>> node appDisable.js false
示例 2
我們再來看一個示例。
// app.disable() 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;
// Disabling the property foo
app.disable('trust proxy');
// Checking the foo property
console.log("Trust proxy settings are set to: ", app.get('trust
proxy'));輸出
C:\home
ode>> node appDisable.js Trust proxy settings are set to: false
廣告
資料結構
網路
RDBMS
作業系統
Java
iOS
HTML
CSS
Android
Python
C 程式設計
C++
C#
MongoDB
MySQL
Javascript
PHP