这是我的js文件
Handlebars.registerHelper('like', function (items, options) {
// 这里省略
});
webpack.config.js文件
引入了handlebars-loader
{
test: /\.handlebars$/,
loader: "handlebars-loader"
}
这样编译会报错,说Handlebars没有定义,该怎么解决呢?原本没定义helper我的handlebars文件可以正常编译
页面要使用handlebar建议直接require handlebar到该页面然后定义为handlebars。这样你才可以自定义handlebars的过滤器helper