简体   繁体   English

车把错误:'车把未定义'

[英]Handlebars error: 'Handlebars is not defined'

I'm new to JS and I have problem in my project.我是 JS 新手,我的项目有问题。 I can't load handlebars.我无法加载车把。 I have the same ReferenceError: handlebars is not defined.我有相同的 ReferenceError:未定义车把。 I've tried also adding handlebars.js file in src folder but it doesn't work.我也尝试在 src 文件夹中添加 handlebars.js 文件,但它不起作用。 I would appreciate any help.我将不胜感激任何帮助。 https://github.com/dzgierski19/pizzeria-project https://github.com/dzgierski19/pizzeria-project

My JS code:我的 JS 代码:

 `const templates = {
    menuProduct: Handlebars.compile(document.querySelector(select.templateOf.menuProduct).innerHTML),
  };`

My HTML我的 HTML

  `<script src="https://cdnjs.cloudflare.com/ajax/libs/handlebars.js/4.1.0/handlebars.min.js"></script>
` `

handlebars error车把错误

Have you tried to change the handlebars version?您是否尝试过更改车把版本? You're using version 4.1.0, but handlebars it's already on version 4.7.7 Theirs any reason to use such an old version?您使用的是 4.1.0 版,但车把已经在 4.7.7 版上 他们有什么理由使用这么旧的版本吗? If you need to use this version, take a look at this version docs to check if it's available and if the methods you're using are right.如果您需要使用此版本,请查看此版本文档以检查它是否可用以及您使用的方法是否正确。

At the official doc the say to use @latest version在官方文档中说要使用@latest 版本在此处输入图像描述

https://handlebarsjs.com/guide/#installation https://handlebarsjs.com/guide/#installation

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM