![](/img/trans.png)
[英]How to call javascript function defined in another file from HTML?
[英]how to call a function of a javascript file from another javascript file without using HTML in titanium
嗨,我正在使用Appcelerator構建iOS應用,
我有一個文件app.js
和一個文件webService.js
文件webService.js包含function x
現在從我的app.js
文件中,我想調用webService.js
文件中存在的function x
。
我搜索了很多,但我只發現使用html..i並沒有使用任何html,它只是純JavaScript。
您是否嘗試過使用
Ti.include('path/file.js');
使用將文件包含在app.js中:
Ti.include('path/webService.js');
並調用該函數。
從Titanium 3.3開始不推薦使用Ti.include
,它在我的環境中不起作用。 如果您使用的是咖啡,請嘗試嘗試濃咖啡 ,盡管它有點丑陋。
好吧,您可以使用include,但是我建議您看一下commonjs。 Commonjs是構建appcelerator應用程序的未來。
你應該檢查一下
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.