【发布时间】:2021-12-27 01:08:55
【问题描述】:
我想使用 React 或本示例中经常使用的这种形式 react-redux
import redux, { useSelector, useDispatch } from 'react-redux';
所以我尝试了明显的:
我创建了一个导出文件:
const exp = {};
exp.a = 'a-1';
exp.b = 'b-1';
export default exp;
还有一个要导入的文件:
import {a, b} from './40-export.js'; // this does not work
// import test from './40-export.js'; // this works
// const {a, b} = test; // this works
【问题讨论】:
-
您似乎混淆了命名导入和对象解构。不要导出对象,而是使用
export const a = 'a-1'
标签: javascript reactjs import export