React Native中的导入类型不同吗?

5 react-native react-native-android react-native-ios

在React Native中,我们必须使用以下方法导入包。

  1. 从“ react-native-router-flux”导入{操作};
  2. 从'react-native-push-notification'导入PushNotification;

这些导入语句之间有什么区别?

Vik*_*Seč 5

当您导出这样的组件/事物时

export class Foo extends Component {…
Run Code Online (Sandbox Code Playgroud)

您必须像这样导入

import {Foo} from './foo.js'
Run Code Online (Sandbox Code Playgroud)

当您默认导出时,就像这里

export default class Bar extends Component {…
Run Code Online (Sandbox Code Playgroud)

您可以像这样导入

import Bar from './bar.js'
Run Code Online (Sandbox Code Playgroud)

当然,每个文件可能只有一个默认导出。