本文介绍了烬手柄:找到哪个插件定义助手(不存在于应用程序/助手)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

很难找出不在 app / helpers 中的助手的位置。助手名字非常普遍,我在我的package.json中搜索了助手的名字,但没有任何东西。



给定一些帮助程序( {{完全通用名称param1 =foo}} )如何找到它的定义?



(我恰好在Ember 2.13上) (注意:帮助器包含 ember-composable-helpers $ c>,因此在helper中搜索package.json会很有帮助,但这是一种非常繁琐的直接搜索方式,甚至可能不会得到答案)。$ b $对于我来说,最简单的方法是运行应用程序的开发版本( ember serve ),打开浏览器的开发工具并打开一个名为< your-app-name> / helpers /< helper-name> .js 的文件。



让我们假设您的应用程序名称是 foo ,并且您已经安装了余烬阵列辅助。通过 ember serve 运行你的应用程序并在Chrome中打开它。转到开发工具 Source 部分。在 Network 小节中搜索 helpers / array.js 。您可以通过 + 为每个名称搜索文件。如果助手是由附件提供的,则该文件是自动生成的。它看起来像下面这样:

$ $ p $ code> define('foo / helpers / array',['exports','ember-array- helper / helper / array'],function(exports,_array){
'use strict';

Object.defineProperty(exports,__esModule,{
value:true
);
Object.defineProperty(exports,'default',{
enumerable:true,
get:function(){
return _array.default;
}
});
});

在第一行中,读取导入的名称 ember-array-helper / helpers / array ,您可以从中猜出插件名称(第一部分)。请注意,您还可以通过打开 /assets/addon-tree-output/ember-array-helper/helpers/array.js 来打开由addon通过开发人员工具导出的实际助手。 。由于最后一部分来自导入,因此您可以轻松使用该部分来搜索文件。现在放置断点并尽可能多地检查这些代码。



同样的方法应该适用于所有主流浏览器。


Having a hard time finding out where a helper not in app/helpers is defined. The helper was very generically named, I searched my package.json for the helper name but there was nothing. I was stuck hunting around with google to try and figure out what addon defined it.

Given some helper ({{totally-generic-name param1="foo"}}) how would one go about finding where it's defined?

(I happen to be on Ember 2.13)

(Note: the helper was contains defined in ember-composable-helpers, so it would have been a LITTLE helpful to search package.json for "helper" but that is a pretty tedious in-direct way of searching, which have may not even yielded the answer)

解决方案

For me the easiest way is to run a development build of your application (ember serve), open development tools of your browser and open a file called <your-app-name>/helpers/<helper-name>.js. In the first line of the file, you see from where it is imported.

Let's assume your application name is foo and you have installed ember-array-helper. Run your application via ember serve and open it in Chrome. Go to development tools Source section. Search for helpers/array.js in subsection Network. You could search for a file per name via +. If the helper is provided by an addon this file is autogenerated. It looks like the following:

define('foo/helpers/array', ['exports', 'ember-array-helper/helpers/array'], function (exports, _array) {
  'use strict';

  Object.defineProperty(exports, "__esModule", {
    value: true
  });
  Object.defineProperty(exports, 'default', {
    enumerable: true,
    get: function () {
      return _array.default;
    }
  });
});

In first line your read the name of the import ember-array-helper/helpers/array from which you can guess on the addon name (first part). Note that you could also open the actual helper exported by addon via developer tools by opening /assets/addon-tree-output/ember-array-helper/helpers/array.js. Since the last part is coming from the import, you could easily use that one to search for the file. Now place your breakpoints and inspect this code as much as you like.

The same approach should work in all major browsers.

这篇关于烬手柄:找到哪个插件定义助手(不存在于应用程序/助手)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-30 05:26