2015-10-26 33 views
0

我在我的index.html文件中有很多腳本,它們包含我所有的Ractive腳本。我想知道是否有某種方法來組織這一切,並將這些腳本放在不同的html或js文件中。有沒有辦法在不同的html或js文件中分離ractive腳本?

這裏就是我的意思是:

//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對象是在我的指數.html,並且無法包含其他html文件。我確信其他人以前有過這個問題,這可能嗎?

+0

你看着使用Ractive組件? – martypdx

+0

是的,但不允許爲每個邏輯分開。 – Omeed

回答

1

你可以使用PHP或其他一些服務器端腳本

<?php 

include_once('a.html'); 

include_once('b.html'); 

include_once('c.html'); 

?> 
+0

這也是我正在做的,並結合Page.js,您可以加載你需要的組件。 – Edward

相關問題