Javascript模板文件

Javascript template file

本文关键字:文件 Javascript      更新时间:2023-11-05

我的html文件中有很多模板,比如

<script id="id1" type="text/template">
  -----
</script>
<script id="tid2" type="text/template">
  -----
</script> -----
----------

这很好,我需要知道,是否可以将这些模板移动到外部文件(javascript或其他类型)中,因为我的html文件需要大量的模板,所以这会产生大量的行。不容易调试或编辑。

将每个脚本移动到一个单独的html或jsp文件中(如果使用),并将它们作为包含在页面中

<link rel="import" href="/path/scriptPage1.jsp"> or 
<c:import url="/path/scriptPage1.jsp"/>