unplugin / unplugin-auto-import

Auto import APIs on-demand for Vite, Webpack and Rollup
MIT License
3.29k stars 198 forks source link

Can it using in Svelte markup? #445

Open kevin82222 opened 12 months ago

kevin82222 commented 12 months ago

Hello, Sorry, this's a question, not a issue😅

In the Vue project, we can auto import inside Vue template, like this:

// vite.config.js

import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import AutoImport from 'unplugin-auto-import/vite'

export default defineConfig({
  plugins: [
    vue(),
    AutoImport({
      vueTemplate: true, // has this option
      {
        'ziggy-js': [
          ['default', 'route'],
        ],
      },
    }),
  ],
})

And without import route from 'ziggy-js' in .vue file.

// App.vue

<template>
  <a :href="route('login')">Login</a>
</template>

But in Svelte, can the same function be implement?

Thanks!

Shigukj commented 6 months ago

我也遇到了这个问题,在模板中无法使用自动导入的方法

Shigukj commented 6 months ago

可能命名冲突,尝试使用其他命名并且不包含$ ,解决了