1
我使用的是燼寶。如何從一個車把JS模板從手柄模板加載css
加載CSS樣式表例如這不起作用
<script type="text/x-handlebars" id="about">
<link rel="stylesheet" href="/static/css/about.css"}}
// HTML CONTENT
.......
</script>
我使用的是燼寶。如何從一個車把JS模板從手柄模板加載css
加載CSS樣式表例如這不起作用
<script type="text/x-handlebars" id="about">
<link rel="stylesheet" href="/static/css/about.css"}}
// HTML CONTENT
.......
</script>
它看起來像它的作品給我。
<script type="text/x-handlebars" data-template-name="color">
<h3>Color</h3>
<link rel="stylesheet" href="http://cdnjs.cloudflare.com/ajax/libs/normalize/2.1.0/normalize.css">
The color of the day is: {{color}}
</script>
嘗試固定}}在<鏈接線的端部。如果這不起作用,您可能需要使用JavaScript加載CSS。 – ccleve
'link'標籤應該總是放在DOM的頭部(根據W3C推薦標準)。如果您需要拆分樣式表,我建議使用控制器來觸發管理樣式表的視圖方法。我可以看到將樣式表放入hbs模板中的吸引力,但它可能會爲您的某些訪問者產生不希望的效果。 –
謝謝@MatthewBlancarte我會很感激jsfiddle。還沒有完全看到我的頭。 –