[英]How do I use Glimmer components inside an Ember app?
The Glimmer website states: Glimmer网站指出:
Just drop your Glimmer components into an Ember app. 只需将您的Glimmer组件放入Ember应用程序即可。 You won't need to change a thing. 你不需要改变一件事。
I've been following the official Ember quick start tutorial . 我一直在关注官方的Ember快速入门教程 。 I replaced the contents of the generated people-list.js
component with this: 我用这个替换了生成的people-list.js
组件的内容:
import Component from '@glimmer/component';
export default class PeopleList extends Component {
}
and I get an error in the browser console stating that @glimmer/component
is undefined. 我在浏览器控制台中收到错误,指出@glimmer/component
未定义。 After I run yarn add @glimmer/component
to add the dependency, I get a new error from Broccoli. 在我运行yarn add @glimmer/component
以添加依赖项之后,我从Broccoli获得了一个新错误。
Additionally, whenever I use '@' before a variable in the people-list.hbs
template, the template fails to compile. 另外,每当我在people-list.hbs
模板中的变量之前使用'@'时,模板就无法编译。 How do I get the Glimmer component to work in my Ember app? 如何在我的Ember应用程序中使用Glimmer组件?
To use glimmer in an ember app today (May 1st, 2019), 今天(2019年5月1日)在ember app中使用glimmer,
yarn add --dev @glimmer/component@beta
then 然后
import Component from '@glimmer/component';
import { tracked } from '@glimmer/tracking';
export default class MyComponent extends Component {
@tracked number = 0;
increment() {
this.number++;
}
}
to see this in action, take a look at a fresh Octane App: https://github.com/ember-cli/ember-octane-blueprint 要了解这一点,请查看新的Octane应用程序: https : //github.com/ember-cli/ember-octane-blueprint
Currently you can't use it for existing ember app. 目前,您无法将其用于现有的ember应用程序。 but you can try it brand new app. 但你可以尝试全新的应用程序。 By installing ember new my-glimmer-app -b https://github.com/glimmerjs/glimmer-blueprint.git
通过安装ember new my-glimmer-app -b https://github.com/glimmerjs/glimmer-blueprint.git
If you go with yarn global add ember-cli/ember-cli
this way then you need to uninstall existing ember-cli ( npm uninstall -g ember-cli
) 如果你使用yarn global add ember-cli/ember-cli
那么你需要卸载现有的ember-cli( npm uninstall -g ember-cli
)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.