Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/visual-studio-2010/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Can';t获取要在Ember.js中渲染的模板部分_Ember.js_Handlebars.js - Fatal编程技术网

Can';t获取要在Ember.js中渲染的模板部分

Can';t获取要在Ember.js中渲染的模板部分,ember.js,handlebars.js,Ember.js,Handlebars.js,我在让Ember.js拾取并渲染车把模板文件时遇到一些问题。我在浏览器的调试控制台中遇到以下错误: 错误:-找不到模板“登录视图” 我在app.js文件的emberjs代码中有以下代码: Welcome = Ember.Application.create(); Welcome.LoginView = Ember.View.extend({ templateName: 'login_view' }); 我的index.html文件中还有以下代码段: <script type="te

我在让Ember.js拾取并渲染车把模板文件时遇到一些问题。我在浏览器的调试控制台中遇到以下错误:

错误:-找不到模板“登录视图”

我在app.js文件的emberjs代码中有以下代码:

Welcome = Ember.Application.create();

Welcome.LoginView = Ember.View.extend({
  templateName: 'login_view'
});
我的index.html文件中还有以下代码段:

<script type="text/x-handlebars">
  {{view Welcome.LoginView}}
</script>

{{view Welcome.LoginView}
最后,相对于app.js文件,我有文件templates/login\u view.handlebar,其中包含要渲染的模板内容:

<form class="form-inline">
  <fieldset>
    <input type="text" name="email" placeholder="email address">
    <input type="password" name="password" placeholder="password">
    <button class="btn btn-primary" type="submit">Sign In</button>
    <!-- ... -->
  </fieldset>
</form>

登录
该错误似乎表明它无法定位把手模板。当我查看生成的HTML时,我没有在页面上看到上面的表单


有人能解释一下我做错了什么吗?

根据你的问题,我假设你没有使用一些工具为你预编译车把模板。Ember在
Ember.templates
数组中查找模板–它不会自动查找位于
templates/
并以
手柄
结尾的模板。如果没有为您编译模板的构建步骤,您必须自己完成这项工作

这听起来可能很复杂,但很简单,如下所示:

Ember.TEMPLATES[“login_view”]=Ember.handlebar.compile('TEMPLATE code');
您必须确保此模板定义在要使用它之前出现


另一种解决方案是将模板内联到
index.html
中,并在脚本标记中添加
data template name=“login\u view”
属性:


但是,如果您的项目有许多模板,那么我建议您采用一个构建工具,为您提供第一个选项



相关问题:

根据您的问题,我假设您没有使用某些工具为您预编译车把模板。Ember在
Ember.templates
数组中查找模板–它不会自动查找位于
templates/
并以
手柄
结尾的模板。如果没有为您编译模板的构建步骤,您必须自己完成这项工作

这听起来可能很复杂,但很简单,如下所示:

Ember.TEMPLATES[“login_view”]=Ember.handlebar.compile('TEMPLATE code');
您必须确保此模板定义在要使用它之前出现


另一种解决方案是将模板内联到
index.html
中,并在脚本标记中添加
data template name=“login\u view”
属性:


但是,如果您的项目有许多模板,那么我建议您采用一个构建工具,为您提供第一个选项


相关问题: