情景再现:在react开发的时候,导入组件、函数时报错:Import in body of module; reorder to top import/first …
原因:在import语句前有变量声明
解决: 变量的声明,要放在import之后
// 错误示例
import { Button, Form, Input, Select, Space, message} from 'antd';
import Pannel from "../../component/Pannel/Pannel"
const { Option } = Select;import {addAccount} from "../../api/account.js"//正确做法
import { Button, Form, Input, Select, Space, message} from 'antd';
import Pannel from "../../component/Pannel/Pannel"
import {addAccount} from "../../api/account.js"//变量声明 放后面,import语句记得放前面
const { Option } = Select;