Comments (10)
@KelseyYau you can use babel-plugin-import
or vite-plugin-style-import
to import component on demand. For example, in thevite
project:
// vite.config.js
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import styleImport from 'vite-plugin-style-import'
export default defineConfig({
css: {
preprocessorOptions: {
less: {
javascriptEnabled: true,
},
},
},
plugins: [
vue(),
styleImport({
libs: [
{
libraryName: '@arco-design/web-vue',
esModule: true,
resolveStyle: (name) => {
return `@arco-design/web-vue/es/${name}/style/index`
},
}
]
})
]
})
And then, you can import component on demand:
<script setup>
import { Button } from "@arco-design/web-vue"
</script>
<template>
<Button type="primary">Primary</Button>
</template>
<style>
</style>
But, it's important to note that the component name doesn't have a default prefix, and I created the issue #39 .
from arco-design-vue.
@WJCHumble 你的方法更加完善,并且让我发现了我导入的是普通 css 而不是 less,所以无法定义 less 变量,还让我认识到了 vite-plugin-style-import 这个按需导入样式的库,谢谢!
上面的配置对我无效,我用的是:
上面的配置在 windows 和 Linux 中表现不一致,可用下面这个保持一致:
const { resolve } = require('path')
styleImport({
libs: [
{
libraryName: '@arco-design/web-vue',
esModule: true,
resolveStyle: (name) => {
return resolve(__dirname+'/node_modules/', '@arco-design/web-vue/es/' + name + '/style/index')
},
}
]
})
from arco-design-vue.
https://github.com/LuckyHookin/vite/blob/arco.design/src/App.vue
import {Notification} from '@arco-design/web-vue';
import '@arco-design/web-vue/es/notification/style/css';
const hello = ()=>{
Notification.info('sdd')
}
https://github.com/LuckyHookin/vite/blob/arco.design/src/components/HelloWorld.vue
<template>
<Trigger :render-to-body="false" trigger="click" show-arrow class="demo-basic" position="top">
<span>Hover Me</span>
<template #content>
123
<input type="button" value="12">
</template>
</Trigger>
</template>
<script setup>
import {Trigger} from '@arco-design/web-vue';
import '@arco-design/web-vue/es/trigger/style/css';
</script>
额。。我不知道这样是不是正确的,但确实可以用。
from arco-design-vue.
@KelseyYau Get it, we will add On-demand Import guide in docs
from arco-design-vue.
建议补充 babel-plugin-import
配置
from arco-design-vue.
调研了一下,近期会先添加一下 https://github.com/antfu/unplugin-vue-components 插件的支持,方便使用自动引入功能
from arco-design-vue.
调研了一下,近期会先添加一下 https://github.com/antfu/unplugin-vue-components 插件的支持,方便使用自动引入功能
新项目就等着这基础功能了
@WJCHumble 你的方法更加完善,并且让我发现了我导入的是普通 css 而不是 less,所以无法定义 less 变量,还让我认识到了 vite-plugin-style-import 这个按需导入样式的库,谢谢!
上面的配置对我无效,我用的是:上面的配置在 windows 和 Linux 中表现不一致,可用下面这个保持一致:const { resolve } = require('path') styleImport({ libs: [ { libraryName: '@arco-design/web-vue', esModule: true, resolveStyle: (name) => { return resolve(__dirname+'/node_modules/', '@arco-design/web-vue/es/' + name + '/style/index') }, } ] })
@WJCHumble 你的方法更加完善,并且让我发现了我导入的是普通 css 而不是 less,所以无法定义 less 变量,还让我认识到了 vite-plugin-style-import 这个按需导入样式的库,谢谢!
上面的配置对我无效,我用的是:上面的配置在 windows 和 Linux 中表现不一致,可用下面这个保持一致:const { resolve } = require('path') styleImport({ libs: [ { libraryName: '@arco-design/web-vue', esModule: true, resolveStyle: (name) => { return resolve(__dirname+'/node_modules/', '@arco-design/web-vue/es/' + name + '/style/index') }, } ] })
有没有试过打包后是否 tree shaking 了呢?
from arco-design-vue.
@flsion 请问支持unplugin-vue-components
插件有什么进展吗?
from arco-design-vue.
@flsion 请问支持
unplugin-vue-components
插件有什么进展吗?
+1
from arco-design-vue.
Already merged unplugin/unplugin-vue-components#252, wait for unplugin-vue-components
release version
from arco-design-vue.
Related Issues (20)
- add video preview HOT 1
- descriptions 组件 在设置了table-layout="fixed"以及column后,第二行的位置产生了偏移
- upload 选择文件后,无法获取选择的文件path路径
- 描述列表 Descriptions渲染列错误 HOT 1
- 描述列表 Descriptions渲染列错误 HOT 1
- @arco-design/web-vue 2.55.0
- a-form-item slot nested modal verification time and style disorder HOT 1
- select search 无法触发事件
- 期望实现对Tab可拖动位置
- dropdown下拉菜单在使用a-dropdown-button,并添加button-props属性时,针对于右侧图标的按钮,添加的按钮属性未对图标按钮生效
- 在 a-list 下面使用 <a-image-preview-group 时, 如果list有更新, 则 a-image-preview-group 中的 src-list 不生效
- Cascader 级联选择器 希望提供 仅显示最后一级 能力 HOT 1
- TreeSelect 能否增加一个default-expand-all属性?
- 远程搜索选择完选项后,无法将 options 回滚到未进行搜索的状态
- 动态表单用[]校验无法验证通过
- vue中使用jsx导入Carousel组件,使用时不生效
- Table组件树结构使用虚拟滚动时子级无法展开
- Modal开启拖动时,允许overflow
- 树选择 TreeSelect 是否可以新增 check 事件 HOT 1
- Tree组件half-checked-keys的绑定值不正确 HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from arco-design-vue.