Vue3 uses Vite to package and report Rollup failed to resolve import “xxx/node_modules/ant-design-vue/xxxx

When using vue3 + vite + ant design vue, when some components of antd are introduced, there is usually no error in the operation, but the packaging will report an error, for example:

Rollup failed to resolve import "D:/xxxxx/node_modules/ant-design-vue/es/form-item-rest/style/index" from "src/views/xxx/xxx.vue". 15:01:51 This is most likely unintended because it can break your application at runtime. If you do want to externalize this module explicitly add it to build.rollupOptions.externalReport some component errors about ant design vue,


solve:

  <template>
  	<FormItemRest>
  		<a-input v-moal:value='val' />
  	</FormItemRest>
  </template>
  <script lang='ts' setup>
  	import {
    
     ref } from 'vue';
    import {
    
     Form } from 'ant-design-vue';
	const FormItemRest = Form.ItemRest; //正解
	const val = ref('');
  </script>

Guess you like

Origin blog.csdn.net/sxs7970/article/details/128150699