我的index.html文件中有很多脚本,其中包含了我所有的Ractive脚本。我想知道是否有一些方法来组织这一切,并将这些脚本放在不同的html或js文件中。
我的意思是:
//index.html
<script type="text/html" id="template-1">
...content...
</script>
<script type="text/html" id="template-2">
...content...
</script>
<script type="text/html" id="template-3">
...content...
</script>以下是我想要实现的目标
//template1.html or js
<script type="text/html" id="template-1">
...content...
</script>
//template2.html or js
<script type="text/html" id="template-2">
...content...
</script>
//template3.html or js
<script type="text/html" id="template-3">
...content...
</script>我尝试过这样做,但我得到了错误,因为我的ractive对象在我的index.html上,并且没有办法包含其他html文件。我相信其他人以前也有过这样的问题,这可能吗?
发布于 2015-10-27 06:18:58
您应该使用每个文件的components。这允许您将一个组件打包到一个文件、脚本、样式和标记中,同时保持它们之间的分离。为了使用组件,你需要使用available in just about every module management/bundling system out there的加载器。
发布于 2015-10-28 22:48:17
您可以使用php或其他服务器端脚本
<?php
include_once('a.html');
include_once('b.html');
include_once('c.html');
?>https://stackoverflow.com/questions/33354125
复制相似问题