unplugin-vue-components
unplugin-vue-components copied to clipboard
自动引入,引入出现错误
//types.ts
export const enum Flow {
'START_NODE' = 'START_NODE',
}
//test.vue
impor {Flow} from './types;
import { reactive } from 'vue';
const data = reactive({
kind : Flow.START_NODE
})
run的时候,auto-imports.d会自动添加 const TART_NODE: typeof import('tdesign-vue-next')['ART_NODE']
终端就会报Internal server error: Failed to resolve import "tdesign-vue-next/es/a-r-t_-n-o-d-e/style" from "src\models\flownodedesigner\flownodedesigner.ts". Does the file exist
看了下https://github.com/antfu/unplugin-vue-components/blob/main/src/core/resolvers/tdesign.ts,也没明白为什么出现这样的问题,name.match(/^T[A-Z]/ name是怎么获取的
https://github.com/antfu/unplugin-vue-components/blob/cb8f9325ffdaeb74927d823095a30d2ec9a262a9/src/core/utils.ts#L28
suppose you using a component name with full uppercase. This is out of range.
normally, a compont name like TartNode will be splitted with Uppercase (T/N) then combine with -
-> Tart-Node -> toLowercase
In your case, TART_NODE will transform to a-r-t_-n-o-d-e
Also, seems TART_NODE is not a tdsign component as well. use your own resolver pls
It seems to be a bug, please provide a minimum reproduction repo. https://antfu.me/posts/why-reproductions-are-required-zh
我这个并不是个组件,但是被解析了
name.match(/^T[A-Z]/
your own code 'TART_NODE' matchs the naming rule(start with T) that will trigger the tdesign process.
我的code是START_NODE ,是S开头的啊
'TART_NODE'这个code在我代码里都没出现出现过
每次出现这个问题,都是我是用类似样式 a.THE 或者 a.STHE,使用对象属性,为什么会被当做引入呢
const a = { TA: '1' }
let a: any = {} a.STA = '1'
const a = { STA: '1' } a.STA 都会报同样的错误
unplugin-vue-components 插件只解析模板中的内容,unplugin-auto-import 插件会解析 script 中的内容,你可以尝试移除 auto-import 中配置的 TDesignResolver
好的,谢谢