我无法使用durandal启动淘汰赛和验证。淘汰赛本身工作正常。如果有人明白了,我将非常感谢您发布配置。
// 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的行为是否与其他插件不同?
最佳答案
就像我在评论中提到的那样,目前,剔除验证在require.js上还不能很好地发挥作用。在您优化应用程序之前,Durandal在开发过程中始终依赖require.js。
此链接暂时详细说明了解决方法。
http://github.com/Knockout-Contrib/Knockout-Validation/issues/259
关于knockout.js - 在Durandal/SPA应用程序中配置 knockout 验证,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/18033268/