モジュールをロードするためにrequirejsを使用するWebアプリケーションがあります。Web アプリケーションは、どのデスクトップ ブラウザーでも問題なく動作します。また、Cordova でパッケージ化すると、iOS および Android でも動作します。ただし、Windows Phone 8 Cordova アプリケーションのビルド時には機能しません。
次のエラーが表示されます。
「ビューが見つかりません: パス「text!views/shell.html」経由で「views/shell」を検索しました
(デュランダル使用)
次のアプリケーション構造があります。
- lib/require/require.js
- www/app/viewmodels/shell.js
- www/app/views/shell.html
- www/app/main.js
- www/index.html (行を含む: )
- :
www/app/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を構成する方法についてのアイデアはありますか?