你可以选择在 ES6 中使用分号,不过类似:
export default function () {
return 'bar';
} // 这里不需要分号
为什么?因为你需要加分号的是这几种情况:
// 赋值操作
const foo = 'bar';
// 调用函数
bar();
// 例外的,三元表达式的第二操作数不需要分号
const foo = bar ? a() : b();
// 关键字
break;
continue;
// 声明变量
let i;
// 循环语句中的参数
for (i = 5; i; i--) {
console.log(i);
}
// 严格模式下的表达式
"I am a string somewhere in memory.";
Pay now to fund the work behind this issue.
Get updates on progress being made.
Maintainer is rewarded once the issue is completed.
You're funding impactful open source efforts
You want to contribute to this effort
You want to get funding like this too