简体   繁体   English

简单的backbone.js问题

[英]Simple backbone.js issue

For the life of me I cannot figure out why this isnt working... 对于我的生活,我无法弄清楚为什么这不起作用......

It retrieves backbone and underscore no problem, and will not propagate any errors, but it also will not output hello world to the console. 它检索主干并强调没有问题,并且不会传播任何错误,但它也不会向控制台输出hello world。

<body>
 <script src="D:/underscore.js"></script>
 <script src="D:/"></script>


<script type="text/javascript">

  Person = Backbone.Model.extend({
     initialize: function() {
        console.log('hello world');
    }
});


</script>

</body>
</head>

You need to create a new Person. 您需要创建一个新人。 All that you have done at this point is specify the properties of the Person model. 此时您所做的就是指定Person模型的属性。 So add: 所以添加:

var myPerson = new Person();

At the end of your script tag. 在脚本标记的末尾。 And that should work. 那应该有用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM