Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在使用Opal.rb构建一个 javascript 应用程序。应用程序由几个负责应用程序不同部分的框架组成。我遇到的问题是我在 x_frame 中实例化了需要从 y_frame 访问的对象。我现在这样做的方法是写:
window.top.frames.x_frame.Opal.MyClass.$do_something()
但这变得丑陋。有什么办法可以定义一个所有帧都可以全局访问的单例吗?
你不能做这样的事情:
Document.ready? do window = Native(`window`) window[:myvar] = MyClass.new end