Skip to content
鼓励作者:欢迎打赏犒劳

js-template

Handlebars

官网:https://handlebarsjs.com/zh/

很简单,很强大,很好用,文档很详细

html
 "handlebars": "^4.7.8",
vue
<script setup>
    import Handlebars from 'handlebars'
    let str = `<ul class="people_list">
  {{#each people}}
    <li>{{this}}</li>
  {{/each}}
</ul>`
    let template = Handlebars.compile(str);
    let generateCode = template({
      people: [
        "Yehuda Katz",
        "Alan Johnson",
        "Charles Jolley",
      ]
    });
    console.log(generateCode)
</script>

如有转载或 CV 的请标注本站原文地址