Javascript 木偶应用程序未启动且存在';没有错!出了什么问题?
几乎在第一次练习中,我就在尝试David Sulc对Marionette.js(Backbone.js)的温和介绍,我遇到了一个奇怪的问题。当我在chrome或firefox中运行代码时,我在控制台中没有看到任何错误,但显然应用程序尚未启动(否则,木偶呈现的文本应该是可见的)。类似地,“console.log”命令在控制台窗口中也没有显示任何响应。控制台是绝对空白的。没有错误,没有警告。请帮忙 这是密码。请让我知道我到底做错了什么Javascript 木偶应用程序未启动且存在';没有错!出了什么问题?,javascript,jquery,html,backbone.js,marionette,Javascript,Jquery,Html,Backbone.js,Marionette,几乎在第一次练习中,我就在尝试David Sulc对Marionette.js(Backbone.js)的温和介绍,我遇到了一个奇怪的问题。当我在chrome或firefox中运行代码时,我在控制台中没有看到任何错误,但显然应用程序尚未启动(否则,木偶呈现的文本应该是可见的)。类似地,“console.log”命令在控制台窗口中也没有显示任何响应。控制台是绝对空白的。没有错误,没有警告。请帮忙 这是密码。请让我知道我到底做错了什么 <!DOCTYPE html> <html&g
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" >
<title>Marionette Test Contacts</title>
<link rel="stylesheet" href="assets/css/bootstrap.css" />
<link rel="stylesheet" href="assets/css/application.css" />
</head>
<body>
<div class="navbar navbar-inverse navbar-fixed-top">
<div class="navbar-inner">
<div class="container">
<span class="brand">Contact manager</span>
</div>
</div>
</div>
<div id="main-region" class="container">
<p>Content to hide when app starts.</p>
</div>
<script type="text/template" id="static-template">
<p>This is generated by Marionette app.</p>
</script>
<script src="http://code.jquery.com/jquery-1.10.2.js"></script>
<script src="https://raw.github.com/douglascrockford/JSON-js/master/json2.js"></script>
<script src="http://underscorejs.org/underscore.js"></script>
<script src="http://backbonejs.org/backbone.js"></script>
<script src="http://marionettejs.com/downloads/backbone.marionette.js"></script>
<script type="text/javascript">
var ContactManager=new Marionette.Application();
ContactManager.on("initialize:after", function(){
console.log("ContactManager has started!");
var staticView=new ContactManager.StaticView();
ContactManager.mainRegion.show(staticView);
});
ContactManager.start();
</script>
</body>
</html>
木偶试验触点
联络经理
应用程序启动时要隐藏的内容
这是由木偶应用程序生成的
var ContactManager=新的木偶.Application();
ContactManager.on(“初始化:之后”,函数(){
log(“ContactManager已启动!”);
var staticView=new ContactManager.staticView();
ContactManager.mainRegion.show(静态视图);
});
ContactManager.start();
我认为您混淆了两个不同版本的木偶的语法。如果使用的是
start()
,请尝试:
ContactManager.on("start", function(){});
根据文件,事件包括:
- “before:start”/onBeforeStart:在应用程序启动之前和初始值设定项执行之前激发李>
- “start”/onStart:在应用程序启动和初始值设定项执行后激发李>
谢谢@kim gysen!!你说我把不同版本的提线木偶混在一起,这让我很扫兴。我发现问题在于on()函数中的“initialize:after”参数。我应该用“之前:开始”