英文:
Mermaid in docsify return [Object Promise]
问题
在我的docsify文档中实现mermaid时遇到问题
你好,我正在尝试在我的docsify项目中实现mermaid流程图,但我的HTML返回[Object Promise]。
我尝试了不同版本的mermaid,但都没有成功。
以下是我的HTML配置:
<body>
<div id="app"></div>
<link rel="stylesheet" href="//cdn.jsdelivr.net/npm/mermaid/dist/mermaid.min.css" />
<script src="//cdn.jsdelivr.net/npm/mermaid/dist/mermaid.min.js"></script>
<script>
var num = 0;
mermaid.initialize({ startOnLoad: false });
window.$docsify = {
name: "", // TODO: 更新。
auto2top: true,
coverpage: true,
loadSidebar: true,
subMaxLevel: 2,
themeColor: "#3170a7",
markdown: {
smartypants: false,
renderer: {
code: function (code, lang) {
if (lang == "mermaid") {
return `<div class="mermaid">${mermaid.render("mermaid-svg-" + num++, code)}</div>`;
}
return this.origin.code.apply(this, arguments);
},
},
},
};
</script>
</body>
结果:
我不知道我做错了什么,也找不到很多解决方案。如果这里有人可以帮助我 谢谢
英文:
Implement mermaid in docsify doc without success
Hello i'm trying to implement mermaid flowchart in my docsify project but my html return [Object Promise]
I try with differents version of mermaid but always without success.
Here my conf html
<body>
<div id="app"></div>
<link rel="stylesheet" href="//cdn.jsdelivr.net/npm/mermaid/dist/mermaid.min.css" />
<script src="//cdn.jsdelivr.net/npm/mermaid/dist/mermaid.min.js"></script>
<script>
var num = 0;
mermaid.initialize({ startOnLoad: false });
window.$docsify = {
name: "", // TODO: Update.
auto2top: true,
coverpage: true,
loadSidebar: true,
subMaxLevel: 2,
themeColor: "#3170a7",
markdown: {
smartypants: false,
renderer: {
code: function (code, lang) {
if (lang == "mermaid") {
return `<div class="mermaid">${mermaid.render("mermaid-svg-" + num++, code)}</div>`;
}
return this.origin.code.apply(this, arguments);
},
},
},
};
</script>
</body>
The result:
I don't know what i'm doing wrong and i'don't find many solutions. If someone here can helpe me Thanks
答案1
得分: 1
使用以下版本解决此问题:
使用此链接://cdn.jsdelivr.net/npm/mermaid@9.4.3/dist/mermaid.min.js
但如果有人有解决[object promise]的方法,那会更好。
英文:
Solve this by changing cdn version:
Use this one: //cdn.jsdelivr.net/npm/mermaid@9.4.3/dist/mermaid.min.js
But if someone as a solution to fix the [object promise] it will be better
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论