我有以下代码:下划线使用多种功能于一体的在线
function doSomething(str){
return str+="a";
}
function anotherFunction(str){
return str+="b";
}
_.mixin({
doSomething:doSomething,
anotherFunction:anotherFunction
});
我想使用多个功能于一身行在一起,但我不能管理工作:
var output=_("startingtext").doSomething().anotherFunction();
我设法使用_.chain
工作,但我不确定是否应该使用链,因为在他们的example他们使用的对象和东西,所以我真的怀疑这是字符串操作的方式。
对不起,我是新来强调:(任何帮助表示赞赏
你将不得不用_()重新包装任何输出,例如'return _(str +“a”);'在第一个函数中,在第二个函数中等价。 – Clemens 2012-01-31 19:54:42