- 问题
Vditor主题分为“主题”和“内容主题”两部分,如果只设置了主题,则是深色背景+深色文字,导致什么都看不到,所以需要设置深色内容主题
- 解决
Vdiotr的设置主题有三个参数,其中第一个是主题,第二个是内容主题,第三个是code主题,所以需要初始化完成后,调用
setTheme
重写设置内容主题
/** 设置主题 */
setTheme(theme: "dark" | "classic", contentTheme?: string, codeTheme?: string, contentThemePath?: string): void;
- 代码
const vditor = new Vditor('vditorMain', {
theme: 'dark',
height: '100%',
after: () => {
console.log('编辑器初始化完成')
vditor.setTheme('dark', 'dark')
}
})
- 相关连接