什么是 Meteor 制作

What is Meteor production

我暂时没有使用属性 Meteor.isProduction。 但我想知道什么时候使用它。 我知道的一些事情是:

当您想在生产和开发模式下做一些不同的事情时,您可以使用它。

例如,您可以设置一个函数,如下所示,在开发模式下仅 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.

的用例有所了解