tags | title | created | modified | ||
---|---|---|---|---|---|
|
coding-style |
2019-09-03T14:06:29.976Z |
2020-06-30T05:17:43.290Z |
- export 导出
- 结论是使用命名导出,少用default
- 使用命名导出应该在声明时导出,还是在文件末尾导出本模块所有对象???
- 不能在一个文件中使用上述方法export两次,因为export的对象不可变
export {default as Module} from './module';
is the standard ES6 wayexport Module from './module;
is a proposed ESnext way- A default export is actually a named export with the name default
- When exporting one thing, and inline export is nicer
- because it ensures that you can not change the binding later (ie,
export default function foo() {};
is better thanfunction foo() {} ; export default foo;
)
- because it ensures that you can not change the binding later (ie,
- In most cases, you should be exporting one conceptual thing from a module.
- In other words, if you have both "foo" and "boo", those are two modules and thus should be export defaulted from two separate files.
- If you insist on having them in the same file, then you should be using multiple named exports.
- As far as positioning, there will soon be a linter rule in
eslint-plugin-import
that will require that all export statements are grouped together - so I'd recommend grouping them together and putting them at the bottom of the file. - 参考
- 结论是使用命名导出,少用default
- Conventional Commits (8种)
<type>[(optional scope)]: <description>
- fix: patches a bug in your codebase
- feat: introduces a new feature to the codebase (minor
- refactor: A code change that neither fixes a bug nor adds a feature
- perf: A code change that improves performance
- test: Adding missing tests or correcting existing tests
- docs: Documentation only changes
- build: Changes that affect the build system or external dependencies
- chore: update version or dependencies, release...
- misc: revert, ci, mark, step
- BREAKING CHANGE: a commit that has a footer BREAKING CHANGE:, or appends a ! after the type/scope
- ref