使用插件:unplugin-auto-import

vite.config.js
import AutoImport from 'unplugin-auto-import/vite'
export default defineConfig({
plugins: [

AutoImport({
  imports: ['vue'],
  eslintrc: {
    enabled: false, // Default `false`, only enable when you need //生成一次即可
    filepath: './.eslintrc-auto-import.json', // Default `./.eslintrc-auto-import.json`
    globalsPropValue: 'readonly' // Default `true`, (true | false | 'readonly' | 'readable' | 'writable' | 'writeable')
  }
})

]
})

.eslintrc.js
module.exports = {
extends: [

...
'./.eslintrc-auto-import.json'

]
}