在 Kanso 中使用 underscore.js
Kanso.js 是一个可以让您轻松构建 couchapps 的工具。正如在文档中可以看到的,它包含 underscore.js 模块。
但是我怎样才能在列表视图中准确地使用 underscore.js 方法呢?我必须先要求它吗?例如,我一直在使用 union 方法:
var newArray = oldArray1.union(oldArray2)
or
var newArray = union(oldArray1, oldArray2)
但是,Kanso 在通过 HTTP 请求列表时不断引发类型错误。
Kanso.js is a tool to easily let you build couchapps. As can be read in the documentation it includes the underscore.js module.
But how can I exactly make use of the underscore.js methods in, let's say, a list view? Do I have to require it first? For example I have been playing around a but with the union method:
var newArray = oldArray1.union(oldArray2)
or
var newArray = union(oldArray1, oldArray2)
However, Kanso keeps on raising a typeError when requesting the list over HTTP.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
首先
require
文件顶部的underscore
模块。如果您位于 Kanso 的dev
分支(版本 0.0.8),它看起来像这样:在 Kanso 0.0.7 中,它看起来像这样:
然后调用
union
来自下划线对象编辑:
在 Kanso 0.2.1(撰写本文时的当前版本)中,下划线有自己的包。使用方法如下:
在 kanso 中添加
下划线
作为依赖项。 json 文件。在项目目录中运行
kanso install
。模块中需要
下划线
。First
require
theunderscore
module at the top of your file. If you're on thedev
branch of Kanso (version 0.0.8), It looks like this:In Kanso 0.0.7 it will look like this:
Then call
union
from the underscore objectEdit:
In Kanso 0.2.1 (the current version at the time of writing), underscore has it's own package. Here's how to use it:
Add
underscore
as a dependency in your kanso.json file.Run
kanso install
in your project directory.Require
underscore
in a module.