Knokcout JS:未捕获的ReferenceError:操作未定义

时间:2018-10-09 17:35:23

标签: javascript knockout-3.0 knockout-templating

我目前正在使用knokcout js渲染视图。

HTML:

<div data-bind="template: {data: {ui: uistate, action: actionHandler }, afterRender: doStuff}">
   <custom-comp params="onclick: action.print, shouldShow: ui.showPrint">
   </custom-comp>
</div>

custom-comp是我的自定义组件,用于呈现现有数据并执行其他操作。

脚本:

this.doStuff= function(elements) {
    console.info(elements); 
}

但是,即使自定义组件获取了数据,并且一切正常运行,它仍然会引发错误:

Uncaught ReferenceError: action is not defined
    at onClick (eval at createBindingsStringEvaluator (knockout.debug.js:2936), <anonymous>:3:60)
    at Function.evaluateImmediate_CallReadThenEndDependencyDetection (knockout.debug.js:2142)
    at Function.evaluateImmediate_CallReadWithDependencyDetection (knockout.debug.js:2114)
    at Function.evaluateImmediate (knockout.debug.js:2078)
    at Object.ko.computed.ko.dependentObservable (knockout.debug.js:1939)
    at knockout.debug.js:3821

0 个答案:

没有答案