这个JS代码片做了什么? `"显影" !=='生产'`

时间:2016-11-05 22:06:09

标签: javascript boolean

它遍布react.js file

if ("development" !== 'production') {
  var typeofSpec = typeof spec;
  var isMixinValid = typeofSpec === 'object' && spec !== null;

  "development" !== 'production' ? warning(isMixinValid, '%s: You\'re attempting to include a mixin that is either null ' + 'or not an object. Check the mixins included by the component, ' + 'as well as any mixins they include themselves. ' + 'Expected object but got %s.', Constructor.displayName || 'ReactClass', spec === null ? null : typeofSpec) : void 0;
}

什么时候会出错?它以什么方式有用?它是自动生成的吗?

1 个答案:

答案 0 :(得分:2)

"development" !== 'production'的目的是启用开发模式。之所以这样做,是为了在缩小过程中将块从生产版本中删除。

为生产而建造时,"production" !== "production"永远不会是true,因此,缩小器会删除该块。