[英]Is ko.mapping.fromJS method depreceated in knockout 2.2 and 3?
I'm having a problem to use ko.mapping.fromJS(
in knockout. I've been testing on version 2.2 and 3. Anybody else who has had problems? Or are there any other alternatives to updating a instatieted viewmodel? 我在淘汰赛中使用
ko.mapping.fromJS(
遇到问题。我已经在2.2和3版上进行过测试。是否还有其他人遇到问题?或者是否有其他替代方法来更新视图模型?
if (PAGE.blogViewModel == null) {
PAGE.blogViewModel = new BlogViewModel(data);
ko.applyBindings(PAGE.blogViewModel, document.getElementById("blog_container"));
} else {
ko.fromJSON(data, PAGE.blogViewModel);
}
The updating ko.fromJSON(data, PAGE.blogViewModel);
更新
ko.fromJSON(data, PAGE.blogViewModel);
does not work. 不起作用。
*TypeError: ko.fromJSON is not a function*
And oddly enough I've used ko.mapping.fromJS(
before and it has worked. 奇怪的是,我之前使用过
ko.mapping.fromJS(
并且它已经起作用了。
ko.mapping.fromJS(data, PAGE.blogViewModel);
ko.mapping.fromJS(data,PAGE.blogViewModel);
TypeError: ko.mapping is undefined TypeError:ko.mapping未定义
ko.mapping.fromJS
is not deprecated because it was never part of the core Knockout library. 不建议不使用
ko.mapping.fromJS
因为它从来都不是核心Knockout库的一部分。
The ko.mapping.fromJS
is comming from the Knockout Mapping plugin . ko.mapping.fromJS
来自Knockout Mapping插件 。
You need to download and include it separately in your HTML to use it. 您需要下载并将其单独包含在HTML中才能使用。
It sounds like you haven't included the ko.mappings-library . 听起来您好像还没有包含ko.mappings-library 。 Make sure that it is loaded after Knockout is loaded.
确保在加载Knockout之后将其加载。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.