2016-11-09 126 views
0

我在流星項目流星HTML不會呈現

client/ 
    src/ 
     test1.js 
     test2.js 
    main.css 
    main.js 
    main.html 
server/ 

main.html FE的結構如下:

<head> 
    <title>meteorTest</title> 
</head> 

<body> 
    <h1>Welcome to Meteor!</h1> 

    {{> hello}} 

</body> 

<template name="hello"> 
    <canvas id="canvas"></canvas> 
</template> 

但是輸出是空的,這意味着閹了<h1>也不canvas顯示在DOM中。當我刪除src - 文件夾時,將呈現<h1>canvas

可能是什麼問題?

回答

1

把你的頭部內容放在head.html文件中 不需要body元素。 將其替換爲div,它將由Meteor自動呈現在body元素中。

1

我會組織你的文件這樣的:

client/ 
    src/ 
     test1.js // Since it seems working when you remove them, 
     test2.js // somethings seems wrong with their code. Maybe post it? 
    helpers/ 
     body.js 
    templates/ 
     body.html 
     hello.html 
    main.css 
    main.js 
    main.html 
server/ 

隨着body.html:

<body> 
    <h1>Welcome to Meteor!</h1> 
    {{> hello}} 
</body> 

隨着hello.html的:

<template name="hello"> 
    <canvas id="canvas"></canvas> 
</template> 

然後在身體JavaScript代碼。 js:

import '../templates/body.html'; 
import '../templates/hello.html'; 

//All your JS code here or imports of other .js 
在客戶端根目錄文件夾

然後:

main.html中:

<head> 
    <title>meteorTest</title> 
</head> 

最後,所有你必須把你的main.js文件:

import './helpers/body.js' 

通常,在項目的根目錄中有一個單獨的「導入」文件夾是有意義的。您可以用這種方式聲明服務器端和客戶端代碼,並確定在服務器/客戶端上導入了哪些代碼。由於您的項目看起來更像是流星測試,並且您還沒有服務器代碼,所以上面的結構應該現在就做。