Commit a821ffc9 by 初志鑫

更新markdown演示组件调用方式

parent 8f3c48d8
import request from "axios";
export function getList() {
return request({
url: "https://cdn.jsdelivr.net/gh/prettier/prettier@master/docs/options.md",
method: "get",
});
}
...@@ -16,8 +16,7 @@ ...@@ -16,8 +16,7 @@
<script> <script>
import marked from "marked"; import marked from "marked";
import "github-markdown-css/github-markdown.css"; import "github-markdown-css/github-markdown.css";
import md from "./js/markdown"; import { getList } from "@/api/markdown";
export default { export default {
name: "Markdown", name: "Markdown",
data() { data() {
...@@ -43,11 +42,12 @@ export default { ...@@ -43,11 +42,12 @@ export default {
this.value = val; this.value = val;
this.fetchData(); this.fetchData();
}, },
fetchData() { async fetchData() {
this.listLoading = true; this.listLoading = true;
switch (this.value) { switch (this.value) {
case "0": case "0":
this.prettierList = marked(md || "", { const { data } = await getList();
this.prettierList = marked(data || "", {
renderer: new marked.Renderer(), renderer: new marked.Renderer(),
gfm: true, gfm: true,
tables: true, tables: true,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment