logo
  • 教程列表
  • SO官方文檔
  • 環境檢測
    • 高階環境配置
    • 使用 METEOR SETTINGS 指定 app 引數
    • 伺服器上的環境檢測
    • 使用 Meteor 方法檢測客戶端環境
    • 使用 NODE ENV 進行客戶端環境檢測
  1. StackOverflow 文件
  2. meteor 教程
  3. 環境檢測
  4. 使用 NODE ENV 進行客戶端環境檢測

使用 NODE ENV 進行客戶端環境檢測

Created: November-22, 2018

從 Meteor 1.3 開始,Meteor 現在預設在客戶端上公開 NODE_ENV 變數。

if (Meteor.isClient) {
  Meteor.startup(function () {
    if(process.env.NODE_ENV === "testing"){
      console.log("In testing...");
    }
    if(process.env.NODE_ENV === "production"){
      console.log("In production...");
    }
  });
}
  • 使用 Meteor 方法檢測客戶端環境

Copyright © 2018. All right reserved

tastones.com 备案号:鲁ICP备18045372号-1

  • 關於本站
  • 免責聲明