我希望我的面板在单击时重新渲染.
但是,当我执行单击时,我得到以下内容:
Uncaught TypeError: Cannot call method 'get' of undefined
Run Code Online (Sandbox Code Playgroud)
看来,我正在记录的"这个"实际上就是模型本身:
_callbacks: Object
_changed: true
_escapedAttributes: Object
_previousAttributes: Object
attributes: Object
cid: "c0"
collection: r.d
id: "f5589ba4-a0aa-dd86-9697-30e532e0f975"
__proto__: n
Run Code Online (Sandbox Code Playgroud)
我无法通过将我的上下文传递给model.bind来弄清楚为什么不能保留适当的"this".
这是我的代码:
// Models
window.Panel = Backbone.Model.extend({
defaults: function(){
return {
flipped: false,
};
},
toggle: function(){
this.save({flipped: !this.get("flipped")});
},
});
// Collections
window.PanelList = Backbone.Collection.extend({
model:Panel,
localStorage: new Store("panels"),
flipped: function(){
return this.filter(function(panel){ return panel.get("flipped"); })
}
});
// Global collection of Panels
window.Panels = new PanelList;
// Panel View …Run Code Online (Sandbox Code Playgroud) toFloat :: (Floating a) => String -> a
toFloat s = read s :: Float
main = print (toFloat "1")
Run Code Online (Sandbox Code Playgroud)
给我错误:
Could not deduce (a ~ Float)
from the context (Floating a)
Run Code Online (Sandbox Code Playgroud)
我确定我遗漏了一些基本的东西,但似乎我的toFloat应该总是返回一个Float,而Float应该意味着浮动.