最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

How to require a custom JavaScript file from ExtJS package resources folder - Stack Overflow

programmeradmin0浏览0评论

I am creating a package for ExtJS 6 where I need to include an external JavaScript file as a resource.

I placed the file in the resources folder of my package, but I can't seem to find any documentation on how to use Ext.require() to load this file.

I could use Ext.require(Ext.resolveResource("<@MyPackage>custom") - that downloads and executes the Sencha/build/production/MyApp/classic/resources/MyPackage/custom.js but it also plains that it cannot load the class from this file:

[E] [Loader] The following classes failed to load:
[E] [Loader] Sencha/build/production/MyApp/classic/resources/MyPackage/custom from Sencha/build/production/MyApp/classic/resources/MyPackage/custom.js

Can Ext.require() be used for this purpose or do I have to use Ext.AJAX and create the <script> tag by myself?

I am creating a package for ExtJS 6 where I need to include an external JavaScript file as a resource.

I placed the file in the resources folder of my package, but I can't seem to find any documentation on how to use Ext.require() to load this file.

I could use Ext.require(Ext.resolveResource("<@MyPackage>custom") - that downloads and executes the Sencha/build/production/MyApp/classic/resources/MyPackage/custom.js but it also plains that it cannot load the class from this file:

[E] [Loader] The following classes failed to load:
[E] [Loader] Sencha/build/production/MyApp/classic/resources/MyPackage/custom from Sencha/build/production/MyApp/classic/resources/MyPackage/custom.js

Can Ext.require() be used for this purpose or do I have to use Ext.AJAX and create the <script> tag by myself?

Share Improve this question asked Jan 26, 2016 at 13:20 KnaģisKnaģis 21.5k9 gold badges70 silver badges80 bronze badges 5
  • Have you tried edition app.json? – Dumbledore Commented Jan 26, 2016 at 13:31
  • Since I am creating a package, editing app.json seems wrong as it is outside the package code. – Knaģis Commented Jan 26, 2016 at 13:32
  • Are you creating a new class or overriding existing classes? – Dumbledore Commented Jan 26, 2016 at 13:34
  • new ponents that extend Ext.Component. – Knaģis Commented Jan 26, 2016 at 14:11
  • IMO, you need to add the files as resource in app.json (after the ExtJS bundle, of course), so that you ExtJS can load you package at app start and you can use these class just like an existing class. Second option is that you can use Ext.Loader. However, I'd like to know other people's thoughts/opinions as well. – Dumbledore Commented Jan 26, 2016 at 15:37
Add a ment  | 

2 Answers 2

Reset to default 2

Edit app.json and look for js property or add it in case it is not there.

...
"js": [
    {
        "path": "lib/myExternalLibrary.js",
        "includeInBundle": true
    },
]
...

reference https://docs.sencha./cmd/6.x/microloader.html#js

Maybe its already to late, but this works for ExtJs6 in your package.json

"js" : [{
    "path": "resources/js/OpenLayers.js",
    "bundle": true
}]
发布评论

评论列表(0)

  1. 暂无评论