模块导出-在React Native中获取未定义的属性'default'

时间:2018-12-20 09:45:48

标签: javascript react-native babeljs eslint es6-modules

导入和导出文件时遇到的问题。这与本机0.51.0

一起使用

但不是本机:0.56

"babel-eslint": "7.2.3",
"babel-plugin-transform-remove-console": "6.9.0",
"babel-preset-react-native": "^5",

module.exports和export default或babel版本是否有问题?

说错了

  

无法读取未定义的属性“默认”
  Object.get [作为API]

repolib / index.js

import * as components from './components';
import * as utils from './utils';

var Utils = {
  Logger: utils.Logger,
  Toast: utils.Toast
}

var Components = {
  Button: components.Button
}

module.exports = {
  Utils,
  Components,
}

实用程序/Toast.js

var Toast = require('../repolib').Utils.Toast;
export default {
  ...(Toast)
}

API / loginAPI.js

import Toast from '../Utils/Toast';
export default {
  login: () => {...}
}

API / index.js

import loginAPI from './loginAPI';
export default {
  loginAPI
}

common / index.js

export { default as API } from '../API';

enter image description here

0 个答案:

没有答案