本文主要是介绍ERROR in [eslint] reorder to top import/first,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
情景再现:在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;
这篇关于ERROR in [eslint] reorder to top import/first的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!