mirror of
https://github.com/certd/certd.git
synced 2026-07-30 09:17:36 +08:00
🔱: [client] sync upgrade with 21 commits [trident-sync]
Update README.md
This commit is contained in:
@@ -0,0 +1,66 @@
|
||||
<template>
|
||||
<pre class="fs-highlight hljs" v-html="highlightHTML"></pre>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
// 相关文档
|
||||
// https://highlightjs.org/usage/
|
||||
// http://highlightjs.readthedocs.io/en/latest/api.html#configure-options
|
||||
import highlight from "highlight.js";
|
||||
import "../highlight-styles/github-gist.css";
|
||||
import htmlFormat from "./libs/htmlFormat";
|
||||
export default {
|
||||
name: "FsHighlight",
|
||||
props: {
|
||||
code: {
|
||||
type: String,
|
||||
required: false,
|
||||
default: ""
|
||||
},
|
||||
formatHtml: {
|
||||
type: Boolean,
|
||||
required: false,
|
||||
default: false
|
||||
},
|
||||
lang: {
|
||||
type: String,
|
||||
required: false,
|
||||
default: ""
|
||||
}
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
highlightHTML: ""
|
||||
};
|
||||
},
|
||||
watch: {
|
||||
code() {
|
||||
this.highlight();
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
this.highlight();
|
||||
},
|
||||
methods: {
|
||||
highlight() {
|
||||
const code = this.formatHtml ? htmlFormat(this.code) : this.code;
|
||||
this.highlightHTML = highlight.highlightAuto(code, [
|
||||
this.lang,
|
||||
"html",
|
||||
"javascript",
|
||||
"json",
|
||||
"css",
|
||||
"scss",
|
||||
"less"
|
||||
]).value;
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
<style lang="less">
|
||||
.fs-highlight {
|
||||
margin: 0px;
|
||||
border-radius: 4px;
|
||||
}
|
||||
</style>
|
||||
Reference in New Issue
Block a user