javascript ko.mapping 未定义

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/9178544/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-26 05:50:24  来源:igfitidea点击:

ko.mapping is undefined

javascriptjqueryknockout.jsknockout-mapping-plugin

提问by kekewong

im following this example http://jsfiddle.net/rniemeyer/badZb/. I just copy and paste the exact code into a sample application and it gave me this error : "ko.mapping is undefined" . Anyone know whats happening? My ko.observable and dependentObservable are working great, is just that ko.mapping is not working.

我正在关注这个例子http://jsfiddle.net/rniemeyer/badZb/。我只是将确切的代码复制并粘贴到示例应用程序中,它给了我这个错误:“ko.mapping is undefined”。有谁知道发生了什么?我的 ko.observable 和dependentObservable 工作得很好,只是 ko.mapping 不起作用。

FYI : The knockout.js version is 2.0 and Jquery 1.7.1

仅供参考:knockout.js 版本是 2.0 和 Jquery 1.7.1

回答by James Allardice

As the mapping plugin is exactly that, a plugin, it is not included in the core library.

由于映射插件正是插件,它不包含在核心库中。

You need to include the mapping pluginseparately. You can find it on GitHub. Just make sure you include it after including the core Knockout library.

您需要单独包含映射插件。您可以在GitHub 上找到它。只要确保在包含核心 Knockout 库之后包含它。