React Native import 檔案的小技巧
開發中經常需要 import 其他 js 檔案,如果需要同時匯入一些相關的 js 檔案時,可以建立一個索引檔案方便引用。
第一步:建立index.js
在 index.js 中 import 相關的 js 檔案
'use strict';
import * as Type from './network/EnvironmentConst';
import Request from './network/RequestManager';
import AppContext from './network/AppContext';
import ApiServiceFactory from './network/ApiServiceFactory';
module.exports = {
ApiServiceFactory,
Type,
Request,
AppContext
};
第二步:使用
如果需要使用這些類,只需要匯入index檔案就可以了~
import {Request, ApiServiceFactory, AppContext, Type} from '../expand/index';
相關文章
- React-native 開發小技巧React
- React Native之檔案操作React Native
- React Native / React除錯技巧React Native除錯
- React開發的小技巧React
- React Native成功過稽核心技巧React Native
- Git 小技巧:忽略某些檔案的更改Git
- react-native 之匯入(import)、匯出(export)深刻解析ReactImportExport
- React Native --踩坑記 之 建立指定 React Native版本的專案React Native
- embed小技巧-動態檔案更新
- 少用@import引入CSS檔案ImportCSS
- git小技巧--提取/合併某分支的部分檔案Git
- 分享 50 個完整的 React Native 專案React Native
- [React Native]react-native-scrollabReact Native
- React-Native專案總結React
- react native 指定版本建立專案React Native
- react-native 開發小結(Android)ReactAndroid
- React import React 無效問題ReactImport
- React Native 學習指南(二) - 天氣小專案實戰演練React Native
- React Native元件佈局應用示例小結React Native元件
- react native社群專案知識點React Native
- react-native 修改專案名稱React
- React Native整合到原生專案示例React Native
- React Native 使用 react-native-webview 渲染 HTMLReact NativeWebViewHTML
- React Native Icon方案:react-native-svgReact NativeSVG
- React Native轉web方案:react-native-webReact NativeWeb
- iOS React Native 混合開發整合React NativeiOSReact Native
- React Native 的未來與React HooksReact NativeHook
- React Native——react-navigation的使用React NativeNavigation
- 利用TypeScript構建優雅的React Native專案TypeScriptReact Native
- [譯] Airbnb 在 React Native 上下的賭注(四):React Native 退役AIReact Native
- Mac小技巧|Mac上如何搜尋隱藏檔案?Mac
- FineUI小技巧(3)表格匯出與檔案下載UI
- 安卓實用小技巧:將App提取為Apk檔案安卓APPAPK
- 平時寫react 小技巧,不錯喲~React
- react-native配置react-native-image-crop-pickerReact
- ecshop二開小技巧-VSCODE 中.t檔案識別為html檔案VSCodeHTML
- React Native整合到現有的原生專案React Native
- 如何在 React Native 專案中使用 MQTTReact NativeMQQT