Using mustache to fill in a html tag argument

前端 未结 1 1752
时光取名叫无心
时光取名叫无心 2021-01-06 13:53

I\'m trying the append an identier (id) to the href below using mustache

Template:


                      
相关标签:
1条回答
  • 2021-01-06 14:28

    You need to add the {{id}} in the href, like that :

    href="#product_detail?{{id}}"
    

    We used to put our mustache template in a script with type="text/template", i don't know if it will solve your escaping problems but we haven't here.

    <script type="text/template" id="tmpl">
       <a href href="#product_detail?{{id}}">link</a>
    </script>
    

    If you got some escaping problems use the & before the id like that:

    <script type="text/template" id="tmpl">
       <a href href="#product_detail?{{& id}}">link</a>
    </script>
    

    Hope it help !

    0 讨论(0)
提交回复
热议问题