0

// 我在 html 页面中有以下代码。我正在尝试这个来学习 Handlebars.compile 功能。

<script src="https://cdnjs.cloudflare.com/ajax/libs/handlebars.js/4.7.7/handlebars.min.js">
</script>
    
<script>
    // compile the template
  let template = Handlebars.compile("Hello {{message}}");
  // execute the compiled template and print the output to the console
  console.log(template({ message: "My friend" }));
</script>

//this outputs in console as - Hello
//But when I test this from console for the same page, like for example

let template2 = Handlebars.compile("Hello {{message}}");
console.log(template2({ message: "My friend" }));
//It outputs - Hello My friend

//I am wondering why same is not working from the page.
4

0 回答 0