Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
511 views
in Technique[技术] by (71.8m points)

extjs - How to use a file from Ext.example

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
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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"/>

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...