遇到麻煩嘗試使用與基因敲除和基因敲除映射合併插件(未淘汰賽映射插件)requireJS,見鏈接在這裏:https://github.com/grofit/knockout.mapping.merge/blob/master/src/knockout.mapping.merge.js與淘汰賽和淘汰賽作圖RequireJS合併插件
腳本:
requirejs.config({
paths: {
'knockout': 'scripts/knockout-3.0.0',
'ko-merge': 'scripts/knockout_mapping_merge'
},
shim: {
'knockout_mapping_merge': {
deps: ['knockout']
}
}
});
require(['knockout', 'ko-merge'], function (ko) {
var vm = function() {
var self = this;
self.forename = ko.observable("FName1");
self.surname = ko.observable("SName1");
self.merge = function() {
var x = {
forename: 'FName2',
surname: 'SName2'
};
ko.mapping.mergeFromJS(self, x);
};
};
ko.applyBindings(new vm());
});
我收到的錯誤是: SCRIPT5007:無法設置未定義或空引用 文件的屬性 'mergeFromJS':knockout_mapping_merge.js,線:41,柱:5
淘汰賽映射合併聲明,像這樣:
(function(knockout){
...
})(typeof exports === 'undefined'? this['ko'] : require("knockout"));
我的理解是,這應該叫淘汰賽作爲一個依賴,但它似乎沒有工作...任何想法,爲什麼?