# 我可以在 Glimmer 单文件组件中使用 routeAction 吗？

**URL:** <https://meta.discourse.org/t/can-i-use-routeaction-in-glimmer-single-file-components/288936>\
**Category:** Development\
**Created:** [2023 年12 月 16 日 22:03 UTC](https://meta.discourse.org/t/can-i-use-routeaction-in-glimmer-single-file-components/288936 "2023-12-16T22:03:38Z")\
**Posts on this page:** 1\
**Showing post:** 1

<div class="post-metadata">

作者： ![manuel](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/manuel/32/468169_2.png) [@manuel](https://meta.discourse.org/u/manuel)\
发布日期： [2023 年12 月 16 日 22:03 UTC](https://meta.discourse.org/t/can-i-use-routeaction-in-glimmer-single-file-components/288936/1 "2023-12-16T22:03:39Z")

</div>

我可以在 .hbs 模板文件中像这样使用 route-action 助手：

```plaintext
@action={{route-action "showLogin"}}

```

我可以在 Glimmer 模板文件中使用相同的声明吗？我尝试过但不起作用：

```plaintext
import { routeAction } from 'discourse/helpers/route-action';

[...]

{{on "click" routeAction "showLogin"}}

```

---

_[View the full topic](https://meta.discourse.org/t/can-i-use-routeaction-in-glimmer-single-file-components/288936)._
