当按需引入的组件依赖其他组件时,依赖的组件css未导入
Closed this issue · 4 comments
Mrchangchang commented
引入的组件依赖其他基础组件时,未导入依赖度基础组件的css
psaren commented
请提供相关代码以复现
Mrchangchang commented
使用Field 组件,依赖cell组件css未导入
<template>
<h1>{{ msg }}</h1>
<div>
<button @click="count++">count is: {{ count }}</button>
</div>
<Button>Vant Button</Button>
<Progress :percentage="3" />
<Field placeholder="请输入"></Field>
<ElButton>element-plus button</ElButton>
</template>
<script lang="ts">
import { ref, defineComponent } from 'vue'
import { Button, Progress, Field } from 'vant'
import { ElButton } from 'element-plus'
export default defineComponent({
name: 'HelloWorld',
components: {
Button,
Progress,
ElButton,
Field
},
props: {
msg: {
type: String,
required: true
}
},
setup: () => {
const count = ref(0)
return { count }
}
})
</script>
<style scoped>
a {
color: #42b983;
}
</style>
psaren commented
应该按下面配置
// vite.config.ts
{
optimizeDeps: {
entries: 'vant/es/**/*.js'
},
plugins:[
vitePluginImp({
libList: [
{
libName: 'vant',
style(name) {
return `vant/es/${name}/style/index.js`
}
}]
})
]
},
}
Mrchangchang commented
谢谢,问题已经解决。