7

我正在尝试使用 GJS(Gnome Javascript)开发一个 Gnome Shell 扩展,但是,我遇到了 Lang 库(我认为它是一个库,如果不正确的话)。但是我在网上找不到任何关于它的资源。

在代码中,它看起来像这样:

const Lang = imports.lang;

const ObjectA = new Lang.Class({ ... });

我在哪里可以找到有关它的一些文档?它是 Gnome 库吗?Mozilla 库?

4

1 回答 1

9

It's a built-in module of gjs -- see modules/lang.js. It includes two main things: bind() (a helper to make "this" point to the logical object in closures) and Class, which basically implements a class in a language that does not have the concept of classes... It would be hard to work with GObject (a class-based object system) without this.

于 2014-03-19T08:59:19.027 回答