no message
Former-commit-id: 0a96bb54e9270e451e59b72e00e35053a7c0e152 Former-commit-id: c250ba90da6546626b9831847630aae786c88344 Former-commit-id: c1182b1bdc6ea9b3934275286a93e2760a643bfe
This commit is contained in:
36
src/components/core/Highlight/index.vue
Normal file
36
src/components/core/Highlight/index.vue
Normal file
@@ -0,0 +1,36 @@
|
||||
<template>
|
||||
<pre 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 {
|
||||
props: {
|
||||
code: {
|
||||
type: String,
|
||||
required: false,
|
||||
default: `console.log('Hello')`
|
||||
}
|
||||
},
|
||||
data () {
|
||||
return {
|
||||
highlightHTML: ''
|
||||
}
|
||||
},
|
||||
mounted () {
|
||||
this.highlight()
|
||||
},
|
||||
watch: {
|
||||
code () {
|
||||
this.highlight()
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
highlight () {
|
||||
this.highlightHTML = highlight.highlightAuto(this.code).value
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
Reference in New Issue
Block a user