在ES6中带有或不带有大括号的导入 [英] Import with or without curly brackets in ES6
本文介绍了在ES6中带有或不带有大括号的导入的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
两者之间有什么区别
import Title from './title.js'
和
import { Title } from './title.js'
?
我认为它与 export default Title;
和 export const Title;
有关,但我不知道.
I think it has some connection with export default Title;
and export const Title;
but I don't know.
推荐答案
(在 developer.mozilla.org
有可能具有默认导出(无论是对象,功能,类等).然后,可以使用import语句来导入此类默认设置.
It is possible to have a default export (whether it is an object, a function, a class, etc.). The import statement may then be used to import such defaults.
最简单的版本直接导入默认值:
The simplest version directly imports the default:
从'/modules/my-module.js'导入myDefault;
参考:https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Statements/import
这篇关于在ES6中带有或不带有大括号的导入的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文