如何在VUE文件中订购导入?
我正在使用更漂亮的,但它没有格式化导入的顺序。
例如,当使用in in in vs code时,我可以按任何顺序导入东西,但是GOFMT总是以正确的顺序对其进行重新排序 - 我猜这是VS代码官方GO扩展的一部分。
如何在VS代码中实现类似的东西?
I am using Prettier but it doesn't format the order of imports.
For example, when using Go in VS Code, I can import stuff in whatever order but Gofmt will always reorder it in the right order - I guess it is part of the official Go extension for VS Code.
How to achieve something like that in Vue in VS Code?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
它看起来像 volar> volar 导入),无论如何,这是VSCODE和VUE3的推荐扩展。 Vetur主要用于Vue2。
这可以用 eslint Too 。这是与VUE + JS有关的任何官方衬里。
由于VUE方法 +组件等自动进来,人们在VUE3中往往没有很多进口。总体上可能有更多的魔术,如
unplugin
软件包。You could use this extension I guess: https://marketplace.visualstudio.com/items ?itemName = amatiasq.sort-imports
It looks like Volar supports this feature (Command palette +
Organize Imports
), it's the recommended extensions for VScode and Vue3 anyway. Vetur being for Vue2 mainly.This can be done with Eslint too. Which is the official linter for anything related to Vue + JS.
People tend to not have a lot of imports overall in Vue3, thanks to auto-imports of Vue methods + components etc. There is maybe more magic overall, as shown by the
unplugin
packages.You could use this extension I guess: https://marketplace.visualstudio.com/items?itemName=amatiasq.sort-imports
还有一个漂亮的插件,该插件支持VUE文件中的格式化导入: htttps://github.com /ianvs/Prettier-Plugin-Sort-Imports (我是维护者)。
There's also a prettier plugin that supports formatting imports in vue files: https://github.com/IanVS/prettier-plugin-sort-imports (I'm the maintainer).