Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

请注意 ES6 模块 export 的 {} 不是对象 #1

Open
liuzhuan opened this issue Jul 5, 2018 · 0 comments
Open

请注意 ES6 模块 export 的 {} 不是对象 #1

liuzhuan opened this issue Jul 5, 2018 · 0 comments
Assignees

Comments

@liuzhuan
Copy link
Owner

liuzhuan commented Jul 5, 2018

ES6 的批量命名导出可以使用如下语法:

const foo = 'foo'
const bar = 'bar'

export { foo, bar }

注意,上面的写法并非对象的简写模式,不能扩展为如下写法:

export {
    foo: foo,
    bar: bar
}

它只是模块化的一种语法形式,在其中可以使用 as 重新命名导出变量:

export { foo as foos, bar as baz }
@liuzhuan liuzhuan self-assigned this Jul 5, 2018
Repository owner deleted a comment Feb 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants
@liuzhuan and others