vue3+vite+typescript出现does not provide an export named ‘xxx’ 解决方法。

在使用TinyMCE富文本组件时,出现以下错误:The requested module ‘/src/main/ts/components/EditorPropTypes.ts?t=1674647216370’ does not provide an export named ‘IPropTypes’。

对应EditorPropTypes.ts中的代码:
export interface IPropTypes {
apiKey: string;
cloudChannel: string;
id: string;
init: EditorOptions;
initialValue: string;
outputFormat: ‘html’ | ‘text’;
inline: boolean;
modelEvents: string[] | string;
plugins: string[] | string;
tagName: string;
toolbar: string[] | string;
modelValue: string;
disabled: boolean;
tinymceScriptSrc: string;
}

解决方法:
import type{ IPropTypes } from ‘./components/EditorPropTypes’;

在import时将import {XXX} from 'XXX’改成import type {XXX} from ‘XXX’
好像vite会出现问题,webpack正常。

发表回复