JavaScript/vue.js/defineAsyncComponent:修订间差异

来自康健生活
Kangkk​(留言 | 贡献)
Kangkk​(留言 | 贡献)
第55行: 第55行:
<syntaxhighlight lang="javascript">
<syntaxhighlight lang="javascript">
const Select = defineAsyncComponent(async () => await import(/* selecct component by es url*/))
const Select = defineAsyncComponent(async () => await import(/* selecct component by es url*/))
</syntaxhighlight>
=== CSS ===
在打包过程中可以通过组件 vite-plugin-css-injected-by-js 将 CSS 合并入 JS 文件中,使用起来也很简单
<syntaxhighlight lang="javascript">
// https://www.npmjs.com/package/vite-plugin-css-injected-by-js
import cssInjectedByJsPlugin from 'vite-plugin-css-injected-by-js'
// ...
  plugins: [
    cssInjectedByJsPlugin(),
// ...
Insert comment here
</syntaxhighlight>
</syntaxhighlight>