我有一个使用requirejs加载其模块的Web应用程序。 Web应用程序在任何桌面浏览器中均可正常工作,与Cordova打包在一起时,它也适用于iOS和Android。然而,在构建Windows Phone 8 Cordova应用程序时不起作用。WP8上的Cordova:requirejs无法解析视图
我得到以下错误:
“查看未找到:搜索: “!意见/壳” 通过路径 “文本的意见/ shell.html”
(我使用迪朗达尔)
我有以下应用程序结构:
- 的lib /要求/ require.js
- WWW /应用程序/的ViewModels/shell.js
- WWW /应用/视图/ shell.html
- WWW /应用/ main.js
- WWW/index.html中(包含行:)
- :
WWW /应用/ main.js包含以下代码:
requirejs.config({
//baseUrl: 'x-wmapp0:www/app',
baseUrl: 'app',
enforceDefine: true,
paths: {
'text': '../lib/require/text',
'durandal':'../lib/durandal/js',
'plugins' : '../lib/durandal/js/plugins',
'transitions' : '../lib/durandal/js/transitions',
'knockout': '../lib/knockout/knockout-2.3.0',
'bootstrap': '../lib/bootstrap3/js/bootstrap',
'jquery': '../lib/jquery/jquery-1.9.1',
'modules' : 'modules'
},
shim: {
'bootstrap': {
deps: ['jquery'],
exports: 'jQuery'
}
}
});
define(['durandal/system', 'durandal/app', 'durandal/viewLocator', 'bootstrap'], function (system, app, viewLocator, bootstrap) {
//>>excludeStart("build", true);
system.debug(true);
//>>excludeEnd("build");
app.title = 'MyApp';
app.configurePlugins({
router: true,
dialog: true,
widget: true
});
app.start().then(function() {
//Replace 'viewmodels' in the moduleId with 'views' to locate the view.
//Look for partial views in a 'views' folder in the root.
viewLocator.useConvention('viewmodels', 'views', 'views');
//Show the app by setting the root view model for our application with a transition.
app.setRoot('viewmodels/shell', 'entrance', 'applicationHost');
});
});
此代码工作完全在WP8以外的所有设备。我试过baseUrl:'x-wmapp0:www/app'来设置WP8 Cordova内部使用的实际路径,但这不起作用。那是因为它不是以'/'或http开头的路径吗?
有关如何配置requirejs以便能够使用requirejs加载模块和视图的任何想法?