Worklight中的Dojo文件缓存

时间:2013-11-11 14:58:25

标签: caching dojo ibm-mobilefirst

使用Dojo文件缓存时,Worklight在Simulator中运行时收到404错误。看起来正在加载的文件没有从公共区域复制到设备。我需要在项目中定义一些其他内容才能实现这一目标吗?必须有一个约定,我希望继续遵循它,因为我希望在项目中有更多的模板文件。

我在.js文件中的define语句:

define(["dojo/_base/lang", "dijit/layout/ContentPane", "dojo/dom", "dojo/text!./templates/Order.html"], function(lang, ContentPane, dom, template){
...
var cp1 = new ContentPane({
            title:"Order",
            content: lang.replace(template, someJson)
         }).placeAt("temp");

我的文件夹结构: 在common / js目录中,我在.js文件中有上面的代码,我有一个模板文件夹来保存Order.html,我希望将来可以存储其他模板文件。

控制台出错:

GET http://localhost:10080/DojoProject/apps/services/preview/DojoApp/windowsphone8/1.0/default/layers/templates/Order.html 404 (Not Found) 

1 个答案:

答案 0 :(得分:0)

似乎您指定路径的方式,浏览器尝试在“layers”文件夹中找到该文件,该文件夹是“模板”的兄弟。

您是否尝试将“dojo / text!./ templates / Order.html”修改为:“dojo / text!./../ templates / Order.html”以向上导航一级,然后转到进入模板文件夹?

我不确定这会有效,但我认为值得一试。