我可以在余烬中使用不同的样式表吗? [英] Can I use different style sheets in ember?

查看:82
本文介绍了我可以在余烬中使用不同的样式表吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用一个应用程序,但声明在视图A中,使用样式表bla,并且在视图B中使用样式表其他。如何使用ember来实现这一点?或者是这样吗?

I would like to use one app, but state that in view A, use style sheet bla, and in view B use style sheet other. How could I achieve this using ember - or is this possible?

推荐答案

你可以使用 didInsertElement 钩子的视图来动态加载样式表和 willDestroyElement 来卸载样式表。有很多SO问题/答案描述了如何进行加载/卸载,这不是Ember特定的。

You could use the didInsertElement hook of the view to dynamically load a stylesheet and willDestroyElement to unload a stylesheet. There are a number of SO questions/answers describing how to do the loading/unloading, which is not Ember-specific.

时间可能有点棘手,因为加载样式表是异步,并且将需要时间,这取决于服务器响应时间,延迟等。

Timing may be a little tricky because loading stylesheets is asynchronous, and will take time depending on server response time, latency, etc.

在大多数情况下,这样做是不值得的,但当然您需要,您需要...

In most cases, it isn't worth the trouble to do this, but of course when you need to, you need to...

有关详细信息,请参阅 Ember.View 的文档我提到的生命周期钩子: http://emberjs.com/api/classes/Ember。 View.html#event_didInsertElement

See the docs for Ember.View for more information about the lifecycle hooks I mentioned: http://emberjs.com/api/classes/Ember.View.html#event_didInsertElement

这篇关于我可以在余烬中使用不同的样式表吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆