什么是 Meteor 制作
What is Meteor production
我暂时没有使用属性 Meteor.isProduction
。
但我想知道什么时候使用它。
我知道的一些事情是:
- Returns
true
在终端输入 meteor --production
时的值。
- “热码推送”不适用于“真”状态。
当您想在生产和开发模式下做一些不同的事情时,您可以使用它。
例如,您可以设置一个函数,如下所示,在开发模式下仅 console.log。
export function devLog(logMe) {
!Meteor.isProduction && console.log(logMe)
}
另一个例子可能是为您使用的另一项服务获取 url,而在开发中您希望使用开发版本或模拟服务,而在生产中您将希望使用生产服务。
export function getServiceUrl() {
return Meteor.isProduction ? 'https://production.example.com' : 'http://localhost:8080'
}
我希望这些简单的示例能让您对使用 Meteor.isProduction.
的用例有所了解
我暂时没有使用属性 Meteor.isProduction
。
但我想知道什么时候使用它。
我知道的一些事情是:
- Returns
true
在终端输入meteor --production
时的值。 - “热码推送”不适用于“真”状态。
当您想在生产和开发模式下做一些不同的事情时,您可以使用它。
例如,您可以设置一个函数,如下所示,在开发模式下仅 console.log。
export function devLog(logMe) {
!Meteor.isProduction && console.log(logMe)
}
另一个例子可能是为您使用的另一项服务获取 url,而在开发中您希望使用开发版本或模拟服务,而在生产中您将希望使用生产服务。
export function getServiceUrl() {
return Meteor.isProduction ? 'https://production.example.com' : 'http://localhost:8080'
}
我希望这些简单的示例能让您对使用 Meteor.isProduction.
的用例有所了解