How to use a file from Ext.example

风格不统一 提交于 2019-12-12 02:34:09

问题


I went through the docs to find for a Ext.example.msg but, i am unable to find it.

According to this example, they have successfully used Ext.example.msg. How is this ?

I had another question on SO which is related to this.

UPDATE

I am trying to use the following code in my application;

Ext.example.msg('Button Click', 'You clicked ta button');

When i execute the code, i get an error saying TypeError: Ext.example is undefined .

To overcome this error i did the following;

1.) added <script type="text/javascript" src="app/extjs/examples/shared/examples.js"/> in my app.html file

2.) added the following in my app.js file

Ext.Loader.setPath('Ext.example', 'app/extjs/examples/shared');

Ext.require(['Ext.container.Viewport',
'Ext.example.*']
); 

None of the above methods works, i still get the same error message.

My project folder structure is as follows;

Project_Name
->app (folder)
--> app.html
--> app.js
--> extjs
  ---> examples
     ---->shared
         ----->example.js

回答1:


When you include your js script in you index.html, as you did in 1:

<script type="text/javascript" src="app/extjs/examples/shared/examples.js"/>

You no longer need loader or to require it - you have explicitly included it and it is clear the script content will be in scope.

It appear to me your path is incorrect: There's no app/extjs and it would make sense to have the extjs folder as sibling to that of your app. Thus this should work:

<script type="text/javascript" src="extjs/examples/shared/examples.js"/>


来源:https://stackoverflow.com/questions/11975911/set-path-in-ext-js-typeerror-ext-example-is-undefined

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!