我无法使用 durandal 启动和运行 knockout.validation。淘汰赛本身工作正常。如果有人明白这一点,我会很感激发布配置。
// main.js
require.config({
paths: {
"libs": "../scripts",
"knockout": "../scripts/knockout-2.2.1",
'knockout.validation': '../scripts/knockout.validation'
},
shim: {
'knockout.validation': {
deps: ["knockout"]
}
}
});
define(function (require) {
validation = require('libs/knockout.validation')
// other dependencies are omitted
ko.validation = validation;
// ko works fine
// ko validation has been set
}
// my viewmodel
define(['services/logger',
'durandal/app',
'durandal/system',
'durandal/plugins/router',
'services/dataservice'],
function (logger, app, system, router, dataservice) {
var user_name = ko.observable().extend( {required: true } );
var user_password = ko.observable().extend( {required: true });
// Unable to get property 'extend' of undefined or null reference
// the same happens, if I define '/libs/knockout.validation locally
kockout.validation 的行为是否与其他插件不同?