简体   繁体   English

如何在余烬路线中引用dom元素?

[英]How to reference a dom element in ember route?

I was working on an EmberJS application developing. 我正在开发EmberJS应用程序。
I defined a route and a template for it 我定义了一条路线和一个模板

And there is a little button, which id is myBtn in that template 还有一个小按钮,该模板中的id是myBtn

I wonder how and when i can reference that button in my route.js 我想知道如何以及何时可以在route.js引用该按钮

If there is no way,i think i may wrote a single component and wrap it in that route(template),course,element reference in component is clearly and easily 如果没有办法,我想我可以编写一个单独的组件,然后将其包装在该route(template)中,组件中的课程,元素引用清晰易懂

Hope there is a hint for me 希望对我有启发

Thanks 谢谢

In most cases there is no need for you to reference dom element (your button) in the route, your button and route should be loosely coupled it is how ember encourages building apps. 在大多数情况下,无需在路径中引用dom元素(您的按钮),按钮和路径应松散耦合,这是ember鼓励构建应用程序的方式。 Instead you should use actions/events to control your app or wrap it in component if you really need reference to dom. 相反,如果您确实需要引用dom,则应该使用actions/events来控制您的应用或将其包装在component

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM