如何关闭 ember 中的弃用警告.js 2.3.



我见过这个:

如何在 Ember.js 中禁用弃用警告?

而这个:

https://coderwall.com/p/ekugbw/turn-off-ember-deprecation-warnings

现在我的代码如下所示:

//app.js
import Ember from 'ember';
import Resolver from 'ember-resolver';
import loadInitializers from 'ember/load-initializers';
import config from './config/environment';
Ember.deprecate = () => {};
Ember.warn = function(i){};

我的环境文件现在包括以下内容:

EmberENV: {
      LOG_STACKTRACE_ON_DEPRECATION: false,
      FEATURES: {
        // Here you can enable experimental features on an ember canary build
        // e.g. 'with-controller': true
      }
    },

这让我得到了我想要的一半结果:日志堆栈跟踪消失了,但我仍然收到一行弃用警告。虽然我将使用这些警告作为将来重构的指南,但这些弃用警告的日志记录会干扰我的调试过程。我需要他们暂时离开。这些弃用的来源很可能是我使用的库(遗留控制器、遗留视图、auth0 等),但无论如何,我需要将这些警告静音,以免它们污染控制台。

我正在使用 Ember 2.3,我怀疑我找到的解决方案(在这个问题中链接)是针对 Ember 1.13 的。

如果你想

有选择地为将来的工作启用弃用,我建议使用ember-cli-deprecations-workflow。

您可以使用 ember install ember-cli-deprecation-workflow 安装它,然后按照自述文件上的说明填充白名单。

您需要停止弃用的登录。试试这个:

RAISE_ON_DEPRECATION = false;

最新更新