gpt4 book ai didi

javascript - ionic 框架中的 app.js 函数冲突

转载 作者:行者123 更新时间:2023-12-03 10:44:24 24 4
gpt4 key购买 nike

我是 ionic 新手,已成功安装并测试了我的第一个教程应用程序。我在使用本教程时遇到以下问题 http://ionicframework.com/docs/guide/building.html

当我创建一个空白项目时,会创建“app.js”,其中包含以下代码:

.run(function($ionicPlatform) {
$ionicPlatform.ready(function() {
// Hide the accessory bar by default (remove this to show the accessory bar above the keyboard
// for form inputs).
// The reason we default this to hidden is that native apps don't usually show an accessory bar, at
// least on iOS. It's a dead giveaway that an app is using a Web View. However, it's sometimes
// useful especially with forms, though we would prefer giving the user a little more room
// to interact with the app.
if(window.cordova && window.cordova.plugins.Keyboard) {
cordova.plugins.Keyboard.hideKeyboardAccessoryBar(true);
}
if(window.StatusBar) {
// Set the statusbar to use the default style, tweak this to
// remove the status bar on iOS or change it to use white instead of dark colors.
StatusBar.styleDefault();
}
});
});

但是,除非我删除上面的 js 代码,否则以下代码将无法工作。所以我的问题是:保留上述代码重要吗?或者我可以取消它吗?如果重要的话我该如何维护这两个代码。

.controller('TodoCtlr', function($scope){
$scope.tasks = [
{title: 'Collect Coins'},
{title: 'Read books'},
{title: 'Go home '},
{title: 'have dinner'}
];
});

感谢您的宝贵时间。

最佳答案

如果我从 run 函数代码的最后一行删除 ; ,该代码就可以工作。这一行就像文件的结尾,因此如果后面有 Controller ,它将无法被识别。它应该看起来像这样:

// run function stuff...
})

.controller('TodoCtlr', function($scope){
// your controller
}); // Here should be the end now!

来源:http://forum.ionicframework.com/t/importance-of-run-function-ionicplatform/17935/3

礼貌:http://forum.ionicframework.com/users/saimon/activity

关于javascript - ionic 框架中的 app.js 函数冲突,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28626833/

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