# **[模塊](http://docs.nativescript.org/core-concepts/modules#modules)**
為了讓你使用目標平臺的本地設備和平臺功能, NativeScript 采用一個模塊化的設計模式。所有設備,平臺或UI功能都位于獨立的模塊內部。要使用模塊提供的功能,你就需要 **require** 該模塊。
在你的項目里,每個模塊的文件駐留在 `tns_modules` 目錄下一個專用的子目錄。每個默認模塊伴都有一個 `package.json` 文件,用來聲明在你的調用之內該模塊如何被調用,并且說明了哪個文件包含模塊自身的代碼。
> `{`
>
> `"name" : "button",`
>
> `"main" : "button.js"`
>
> `}`
* [核心模塊](http://docs.nativescript.org/core-concepts/modules#core-modules)
* [設備功能模塊](http://docs.nativescript.org/core-concepts/modules#device-functionality-modules)
* [D數據模塊](http://docs.nativescript.org/core-concepts/modules#data-modules)
* [用戶界面模塊](http://docs.nativescript.org/core-concepts/modules#user-interface-modules)
* [Layouts](http://docs.nativescript.org/core-concepts/modules#layouts)
* [Widgets](http://docs.nativescript.org/core-concepts/modules#widgets)
* [WHATWG polyfills](http://docs.nativescript.org/core-concepts/modules#whatwg-polyfills)
## [**核心模塊**](http://docs.nativescript.org/core-concepts/modules#core-modules)
* [application](http://docs.nativescript.org/cookbook/application): 為應用抽象提供相關的方法(就是把App當作一個對象?!)。
* [console](http://docs.nativescript.org/cookbook/console): 讓你打印消息到設備控制臺。
* [application-settings](http://docs.nativescript.org/cookbook/application-settings): 讓你存取任何你的應用相關的信息。
* [http](http://docs.nativescript.org/cookbook/http): 讓你發送web請求并接收響應。
* [image-source](http://docs.nativescript.org/cookbook/image-source): 提供了 `ImageSource` 類,就是具體平臺圖片對象的抽象類,被當作圖片源使用(通常是bmp位圖)。
* [timer](http://docs.nativescript.org/cookbook/timer): 讓你創建,啟動,停止和重啟定時器。
* [trace](http://docs.nativescript.org/cookbook/trace): 讓你基于分類跟蹤和打印特定信息。
* [ui\/image-cache](http://docs.nativescript.org/cookbook/ui/image-cache): 提供 `image-cache` 類,它處理圖片下載請求并緩存已經下載的圖片。
* [connectivity](http://docs.nativescript.org/cookbook/connectivity): 讓你檢查互聯網連接并監控其變化。
## [**設備功能模塊**](http://docs.nativescript.org/core-concepts/modules#device-functionality-modules)
* [camera](http://docs.nativescript.org/cookbook/camera): 讓你用設備的相機照像。
* [location](http://docs.nativescript.org/cookbook/location): 讓你使用設備的定位傳感器。
* [platform](http://docs.nativescript.org/cookbook/platform): 提供有關設備,操作系統和軟件的信息。
* [fps-meter](http://docs.nativescript.org/cookbook/fps-meter): 讓你捕獲你app的每秒幀數標準(幀數表)。
* [file-system](http://docs.nativescript.org/cookbook/file-system): 讓你用設備的文件系統工作。 為文件系統實體提供高層次的抽象,如文件、文件夾、已知文件夾、路徑、分隔符等。
* [ui\/gestures](http://docs.nativescript.org/cookbook/ui/gestures): 提供 `GesturesObserver` 類,它讓你發現和響應用戶手勢。
## [**數據模塊**](http://docs.nativescript.org/core-concepts/modules#data-modules)
* [data\/observable](http://docs.nativescript.org/cookbook/data/observable): 提供 `Observable` 類, 在 MVVM 模式里它代表一個可觀察的數據或對象。
* [data\/observable-array](http://docs.nativescript.org/cookbook/data/observable-array): 提供 `ObservableArray` 類,它在一個對象集合里面檢測并響應變動。
* [data\/virtual-array](http://docs.nativescript.org/cookbook/data/virtual-array): 提供 `VirtualArray` 類, 它是一個高級的類似數組的類,有助于按需加載項目(懶加載?)。
## [**UI模塊**](http://docs.nativescript.org/core-concepts/modules#user-interface-modules)
* [ui\/frame](http://docs.nativescript.org/cookbook/ui/frame): 提供 `Frame` 類代表邏輯 `View` 單元,它在一個app里負責導航。
* [ui\/page](http://docs.nativescript.org/cookbook/ui/page): 提供 `Page` 類 , 代表一個邏輯單元用以在 `Frame` 里導航 。NativeScript App 包括若干page。
* [color](http://docs.nativescript.org/cookbook/color): 讓你創建顏色,以便你變換UI樣式時使用。
* [text\/formatted-string](http://docs.nativescript.org/cookbook/formatted-string): 提供 `FormattedString` 和 `Span` 類, 你可以用它們創建富文本格式化字符串。
* [xml](http://docs.nativescript.org/cookbook/xml-parser): 提供`XmlParser` 類, 這是一個用easysax實現的SAX解析器。
* [ui\/styling](http://docs.nativescript.org/cookbook/ui/styling): 提供`Style` 類, 它負責元素的視覺表現。
* [ui\/animation](http://docs.nativescript.org/cookbook/ui/animation): 提供 `Animation` 類, 它可以讓你動畫視圖屬性。
### 布局
* [ui\/layouts\/stack-layout](http://docs.nativescript.org/cookbook/ui/layouts/stack-layout): 提供 `StackLayout` 類, 它讓你在一行內安排子元素的布局。
* [ui\/layouts\/grid-layout](http://docs.nativescript.org/cookbook/ui/layouts/grid-layout): 提供 `GridLayout` 類, 它讓你在一個彈性的格子里用行和列安排子元素的布局。
* [ui\/layouts\/absolute-layout](http://docs.nativescript.org/cookbook/ui/layouts/absolute-layout): 提供 `AbsoluteLayout` 類,它讓你在任意位置安排子元素的布局,或在多個層呈現他們。
* [ui\/layouts\/wrap-layout](http://docs.nativescript.org/cookbook/ui/layouts/wrap-layout): 提供 `WrapLayout` 類 ,它讓你按次序地從左到右,然后從上到下(卷滾)安排子元素布局。
### 窗口小部件
* [ui\/activity-indicator](http://docs.nativescript.org/cookbook/ui/activity-indicator): 提供 `ActivityIndicator` 類, 它表示一個窗口小部件,用于顯示當前正在忙的服務。
* [ui\/button](http://docs.nativescript.org/cookbook/ui/button): 提供 `Button` 類, 它是標準的按鈕部件。
* [ui\/label](http://docs.nativescript.org/cookbook/ui/label): 提供`Label`類 ,它是標準的label 部件。
* [ui\/text-field](http://docs.nativescript.org/cookbook/ui/text-field): 提供 `TextField` 類, 它表示一個可編輯的單行方框。
* [ui\/text-view](http://docs.nativescript.org/cookbook/ui/text-view): 提供 `TextView` 類, 它表示一個可編輯的多行方框 。
* [ui\/list-view](http://docs.nativescript.org/cookbook/ui/list-view): 提供 `ListView` 類, 它表示一個標準的 list view 部件。
* [ui\/image](http://docs.nativescript.org/cookbook/ui/image): 提供`Image` 類, 代表一個圖片部件。
* [ui\/progress](http://docs.nativescript.org/cookbook/ui/progress): 提供`Progress` 類, 代表一個進度或加載指示器。
* [ui\/scroll-view](http://docs.nativescript.org/cookbook/ui/scroll-view): 提供`ScrollView` 類, 代表一個可滾動區域,以顯示超出屏幕可視區域的內容。
* [ui\/search-bar](http://docs.nativescript.org/cookbook/ui/search-bar): 提供`SearchBar` 類,代表一個標準的搜索條部件。
* [ui\/slider](http://docs.nativescript.org/cookbook/ui/slider): 提供 `Slider` 類, 代表一個標準的滑塊部件。
* [ui\/switch](http://docs.nativescript.org/cookbook/ui/switch):提供 `Switch` 類, 代表一個標準的 switch 部件。
* [ui\/tab-view](http://docs.nativescript.org/cookbook/ui/tab-view): 提供`TabView` 類, 代表一個標準的 標簽內容部件。
* [ui\/web-view](http://docs.nativescript.org/cookbook/ui/web-view): 提供 `WebView` 類, 表示一個標準的瀏覽器部件。
* [ui\/html-view](http://docs.nativescript.org/cookbook/ui/html-view): 提供 `HtmlView` 類, 代表一個標準的 html 視圖部件。
* [ui\/dialogs](http://docs.nativescript.org/cookbook/ui/dialogs): 讓你顯示各種對話框,比如警告框,提示框,確認框和其他。
[ui\/list-picker](http://docs.nativescript.org/cookbook/ui/list-picker): 提供 `ListPicker` 類, 表示一個標準的列表選擇組件。
* [ui\/date-picker](http://docs.nativescript.org/cookbook/ui/date-picker): 提供 `DatePicker` 類, 表示一個標準的日期選擇組件。
* [ui\/time-picker](http://docs.nativescript.org/cookbook/ui/time-picker): 提供 `TimePicker` 類, 表示一個標準的時間選擇組件。
* [ui\/placeholder](http://docs.nativescript.org/ui/placeholder): 提供 `Placeholder` 類, 讓你可以添加一個原生窗口部件到視覺樹。
## **[WHATWG Polyfills](http://docs.nativescript.org/core-concepts/modules#whatwg-polyfills)**
* [fetch](http://docs.nativescript.org/cookbook/fetch): The `Fetch` polyfill that provides requests, responses, and the process that binds them: fetching. [https:\/\/fetch.spec.whatwg.org\/](https://fetch.spec.whatwg.org/)