我目前正在使用EmberJS应用程序,我想知道如何使<head>
部分。我已经尝试添加{{render 'shared/head'}}
,但它不会被Ember编译。
我现在拥有的是什么:
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>EmberApp</title>
<meta name="description" content="">
<meta name="viewport" content="width=device-width, initial-scale=1">
{{content-for 'head'}}
<link rel="stylesheet" href="assets/vendor.css">
<link rel="stylesheet" href="assets/whole-new-home.css">
{{content-for 'head-footer'}}
</head>
我希望实现的目标:
<!-- app/index.html -->
...
<head>
{{render 'shared/head'}}
{{content-for 'head'}}
<link rel="stylesheet" href="assets/vendor.css">
<link rel="stylesheet" href="assets/whole-new-home.css">
{{content-for 'head-footer'}}
</head>
...
<!-- app/templates/shared/_head.hbs -->
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>{{appName}}</title>
<meta name="description" content="">
<meta name="viewport" content="width=device-width, initial-scale=1">
答案 0 :(得分:0)
而不是{{render 'shared/head'}}
,请尝试{{partial 'shared/head'}}
。
我认为您会看到类似&#34;未捕获的错误:断言失败:您使用了{{render 'shared.head'}}
,但是&#39; shared.head&#39;无法找到模板或视图。&#34;?另请注意,如果您使用的是Ember CLI,则标准是使用-
而不是_
为部分添加前缀。