gpt4 book ai didi

javascript - WP8 上的 Cordova : requirejs can't resolve views

转载 作者:行者123 更新时间:2023-11-29 16:14:22 26 4
gpt4 key购买 nike

我有一个使用 requirejs 加载其模块的 Web 应用程序。 Web 应用程序可以在任何桌面浏览器中正常运行,如果与 Cordova 打包在一起,它也可以在 iOS 和 Android 上运行。但是在构建 Windows Phone 8 Cordova 应用程序时不起作用。

我收到以下错误:

“未找到 View :通过路径“text!views/shell.html”搜索“views/shell”

(我正在使用 Durandal)

我有以下应用程序结构:

  • 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 加载模块和 View 有什么想法吗?

最佳答案

看看对你有没有帮助http://mikaelkoskinen.net/durandal-phonegap-windows-phone-8-tutorial/

此外,截至 2013 年 10 月 18 日,Phonegap Build 已添加对 WP8 的测试版支持。添加“winphone: 作为 gap:platform 并确保您使用的是 phonegap 3.0。我们目前没有运气,但也许您可以使用它。

关于javascript - WP8 上的 Cordova : requirejs can't resolve views,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19439246/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com