开始使用骨干网和CoffeeScript的 [英] Get started with Backbone and CoffeeScript

查看:66
本文介绍了开始使用骨干网和CoffeeScript的的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我认为这更多的是一种的CoffeeScript 的问题。我希望能够在 foo.coffee 骨干班 >文件。我尝试使用 -r 选项,要求骨干运行时,咖啡命令:

I think this is more of a CoffeeScript question. I want to be able to use classes from Backbone in a foo.coffee file. I tried using the -r option to require Backbone when running the coffee command:

coffee -r "../backbone" -c foo.coffee

编译器抱怨说,骨干是不确定的。我敢肯定,这一定是pretty简单。这是很容易找到使用 CoffeeScript的骨干<人的例子/ A>在一起。我也试过要求的类别在像这样的文件的顶部:

The compiler complained that Backbone was undefined. I'm sure that this must be pretty simple. It's easy to find examples of people using CoffeeScript and Backbone together. I also tried requiring the class at the top of the file like so:

Backbone.model = require('../../backbone').Model

class foo extends Backbone.model

我可以在初始化方法把它写入的console.log 。当我试着写这个的console.log ,我刚刚得到一个空对象 {}

I could write it to console.log in the initialize method. When I tried writing this to console.log, I just got an empty object {}.

谁能告诉我怎么走这回事?

Can anyone tell me how to get this going?

推荐答案

如果您正在使用 CoffeeScript的并的Backbone.js ,我建议您查阅早午餐
它可能只是让你过去你的苦衷。

If you're using CoffeeScript and Backbone.js, I recommend checking out Brunch. It may just get you past your difficulties.

这篇关于开始使用骨干网和CoffeeScript的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆