简体   繁体   English

如何在Ember应用程序中使用Glimmer组件?

[英]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.

相关问题 如何从 glimmer 组件中获取父上下文? - How do I get the parent context from within a component in glimmer? GlimmerJS:如何在不使用ember-cli / broccoli构建的情况下将Glimmer用作lib(例如AMD) - GlimmerJS: how to use Glimmer as a lib (e.g. AMD) without building with ember-cli/broccoli 如何在Ember 3.8中调用嵌套余烬组件 - How do I call nested ember components in Ember 3.8 如何使用Dalek自动进行Ember测试(特定Ember组件的设置/拆卸) - How do I do Automating Ember testing with Dalek (setup/teardown of specific Ember components) 我如何使用下一个图像组件 - How do i use the next image components 如何在应用程序中构建组件的“组合”? - How do I build the “composition” of components in the app? 如何在Ember应用程序中实现嵌套的全局过滤器? - How do I implement nested global filters in an Ember app? 如何在Ember中构建时区检查应用程序 - How do I structure a Timezone Checking App in Ember 如何在我的 Rails 应用资产管道中仅使用 SwiperJS 库的核心组件? - How do I use only core components of the SwiperJS library in my Rails app asset pipeline? Ember.js,如何在视图中使用Javascript? - Ember.js, How do I use Javascript in a view?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM