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除錯技巧React Native除錯
- React Native成功過稽核心技巧React Native
- react-native 之匯入(import)、匯出(export)深刻解析ReactImportExport
- React Native --踩坑記 之 建立指定 React Native版本的專案React Native
- Git 小技巧:忽略某些檔案的更改Git
- React開發的小技巧React
- embed小技巧-動態檔案更新
- 少用@import引入CSS檔案ImportCSS
- [React Native]react-native-scrollabReact Native
- React-Native專案總結React
- React Native Icon方案:react-native-svgReact NativeSVG
- react-native 修改專案名稱React
- react native社群專案知識點React Native
- [20230224]改動資料檔案小技巧.txt
- React Native轉web方案:react-native-webReact NativeWeb
- React Native 使用 react-native-webview 渲染 HTMLReact NativeWebViewHTML
- ecshop二開小技巧-VSCODE 中.t檔案識別為html檔案VSCodeHTML
- 利用TypeScript構建優雅的React Native專案TypeScriptReact Native
- [譯] Airbnb 在 React Native 上下的賭注(四):React Native 退役AIReact Native
- link和@import匯入css檔案的區別ImportCSS
- react-native配置react-native-image-crop-pickerReact
- React Native選擇器元件-react-native-slidepickerReact Native元件IDE
- React Native 的未來與React HooksReact NativeHook
- React Native整合到現有的原生專案React Native
- (零) React Native 專案開發拾遺React Native
- 如何在 React Native 專案中使用 MQTTReact NativeMQQT
- react-nativeReact
- React Native 上手React Native
- python擴充套件檔案import失敗Python套件Import
- import匯入檔案路徑注意點Import
- 《React Native高效開發》之create-react-native-appReact NativeAPP
- React Native 小記 - TouchableOpacity 單次點選無效React Native
- React Native 小記 – TouchableOpacity 單次點選無效React Native
- React Native - react-native-code-push-熱更新外掛的使用[譯文]React Native
- Mac小技巧|Mac上如何搜尋隱藏檔案?Mac
- React Native遇到的問題React Native
- react native的notifee訊息React Native
- React Native專案自動化打包釋出React Native