我有如下的余烬帮助方法
export default () => { Handlebars.registerHelper('ifCond', function (v1, operator, v2, options) { if (params[3]) { //handle case insensitive conditions if 4 param is passed. params[0] = params[0].toLowerCase(); params[2] = params[2].toLowerCase(); } let v1 = params[0]; let operator = params[1]; let v2 = params[2]; switch (operator) { case '==': return (v1 == v2); case '!=': return (v1 != v2); case '===': return (v1 === v2); case '<': return (v1 < v2); case '<=': return (v1 <= v2); case '>': return (v1 > v2); case '>=': return (v1 >= v2); case '&&': return !!(v1 && v2); case '||': return !!(v1 || v2); default: return false; } }); }
我正尝试从我的hbs文件中调用它,如下所示
{{#if (ifCond 'testing' '===' 'testing' true)}}
但是我遇到以下错误,请有人向我提出一些建议,谢谢。contacts.hbs:41未捕获的错误:模块构建失败(来自./.webpack/webpack-handlebars.js):错误:如果每个都不匹配-372:59在validateClose(C:\ SourceCode \ IMS \ Development \ IMS \ IMS.Ember \ node_modules \ ember-source \ dist \ ember-template-compiler.js:11014:13)在Object.prepareBlock(C:\ SourceCode \ IMS \ Development \ IMS \ IMS.Ember \ node_modules \ ember-source \ dist \ ember-template-compiler.js:11125:7)在Object.anonymous(C:\ SourceCode \ IMS \ Development \ IMS \ IMS.Ember \ node_modules \ ember-source \ dist \ ember-template-compiler.js:8339:25)在Parser.parse(C:\ SourceCode \ IMS \ Development \ IMS \ IMS.Ember \ node_modules \ ember-source \ dist \ ember-template-compiler.js:10142:38)在解析时(C:\ SourceCode \ IMS \ Development \ IMS \ IMS.Ember \ node_modules \ ember-source \ dist \ ember-template-compiler.js:11271:36)在预处理时(C:\ SourceCode \ IMS \ Development \ IMS \ IMS.Ember \ node_modules \ ember-source \ dist \ ember-template-compiler.js:5817:71)在预编译时(C:\ SourceCode \ IMS \ Development \ IMS \ IMS.Ember \ node_modules \ ember-source \ dist \ ember-template-compiler.js:3949:38)在Object.precompile(C:\ SourceCode \ IMS \ Development \ IMS \ IMS.Ember \ node_modules \ ember-source \ dist \ ember-template-compiler.js:8119:37)在Object.module.exports(C:\ SourceCode \ IMS \ Development \ IMS \ IMS.Ember.webpack \ webpack-handlebars.js:15:29)在对象。 (http://localhost:58799/Ember/dist/templates.js?version=1572992916177.89:22620:7)
我有一个余烬帮助器方法,如下所示export default()=> {Handlebars.registerHelper('ifCond',函数(v1,运算符,v2,选项){if(params [3]){//句柄.. 。
{{#
表示告诉车把的期望是“ /}}`,如: