需要对页面中的 Markdown 进行渲染,调用静态方法 preview
,如图,想修改成自建cdn,但是配置似乎无效。
看过官方文档解释,发现light.css资源不走给它的自建cdn。。。
light.css由options.preview.theme.path来决定。
然后如此这般...没用
VditorPreview.prevuew(document.getElementById(id), md_text, {
cdn: 你的cdn,
math: {
engine: 'MathJax',
},
preview:{
theme: {
path: 'https://你的.com/Source/vditor/dist/css/content-theme',
},
}
})
看一下这个方法怎么搞的https://github.com/Vanessa219/vditor/blob/master/src/method.ts
然后发现相当于直接就读到options.theme.path了,还以为是options.preview.theme.path。。。
所以应该要把theme提到外面一层。
VditorPreview.prevuew(document.getElementById(id), md_text, {
cdn: 你的cdn,
math: {
engine: 'MathJax',
},
theme: {
path: 'https://你的.com/Source/vditor/dist/css/content-theme',
},
})
就好了。