We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
// sum.js export default function sum(x) { return x + x; } // index.js import * as sum from './sum';
A:sum(4) B: sum.sum(4) C: sum.default(4) D: 默认导出不用*来导入,只能具名导出
答案:C
解析:
使用符号*,我们引入文件中的所有值,包括默认和具分章 名。如果我们有以下文件:
// info.js export const name = 'Lydia'; export const age = 21; export default 'I love JavaScript'; // index.js import * as info from './info'; console.log(info);
将会输出以下内容:
{ default: 'I love JavaScript', name: 'Lydia', age: 21 }
以sum为例,相当于以下形式引入值sum :
{ default: function sum(x) { return x + x }}
我们可以通过调用sum.default来调用该函数
The text was updated successfully, but these errors were encountered:
No branches or pull requests
答案:C
解析:
使用符号*,我们引入文件中的所有值,包括默认和具分章
名。如果我们有以下文件:
将会输出以下内容:
以sum为例,相当于以下形式引入值sum :
我们可以通过调用sum.default来调用该函数
The text was updated successfully, but these errors were encountered: