2016-11-09 151 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' 

通常,在项目的根目录中有一个单独的“导入”文件夹是有意义的。您可以用这种方式声明服务器端和客户端代码,并确定在服务器/客户端上导入了哪些代码。由于您的项目看起来更像是流星测试,并且您还没有服务器代码,所以上面的结构应该现在就做。