no message

Former-commit-id: de9fc7ee6ce7d2874bedb5d51fd2997f52870126
Former-commit-id: 70cb9e2b35ef7a76a62dc085aeb77eb914bc42ab
Former-commit-id: 47e9746d0a0fd6d32e798a0f6fbd684c8b555f09
This commit is contained in:
liyang
2018-06-10 08:43:27 +08:00
parent 8cc55e1bf7
commit 58ec52afac
11 changed files with 27 additions and 25 deletions

View File

@@ -0,0 +1,44 @@
<template>
<pre class="d2-highlight" 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'
export default {
name: 'd2-highlight',
props: {
code: {
type: String,
required: false,
default: `console.log('you lost code prop')`
}
},
data () {
return {
highlightHTML: ''
}
},
mounted () {
this.highlight()
},
watch: {
code () {
this.highlight()
}
},
methods: {
highlight () {
this.highlightHTML = highlight.highlightAuto(this.code).value
}
}
}
</script>
<style lang="scss" scoped>
.d2-highlight {
margin: 0px;
border-radius: 4px;
}
</style>