add highlight option for demos
This commit is contained in:
53
docs/src/components/Prism/index.vue
Normal file
53
docs/src/components/Prism/index.vue
Normal file
@@ -0,0 +1,53 @@
|
||||
<template>
|
||||
<pre :class="`language-${language}`" :data-line="highlight"><code :class="`language-${language}`">{{ code }}</code></pre>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import Prism from 'prismjs'
|
||||
import 'prismjs/plugins/line-highlight/prism-line-highlight.js'
|
||||
import 'prismjs/plugins/line-highlight/prism-line-highlight.css'
|
||||
|
||||
export default {
|
||||
props: {
|
||||
language: {
|
||||
default: 'js',
|
||||
type: String,
|
||||
},
|
||||
|
||||
code: {
|
||||
default: null,
|
||||
type: String,
|
||||
},
|
||||
|
||||
highlight: {
|
||||
type: String,
|
||||
default: null,
|
||||
},
|
||||
},
|
||||
|
||||
watch: {
|
||||
highlight() {
|
||||
this.$nextTick(this.highlightCode)
|
||||
},
|
||||
},
|
||||
|
||||
methods: {
|
||||
highlightCode() {
|
||||
|
||||
Prism.highlightAllUnder(this.$el)
|
||||
}
|
||||
},
|
||||
|
||||
mounted() {
|
||||
this.highlightCode()
|
||||
},
|
||||
|
||||
beforeDestroy() {
|
||||
console.log('JOOOO')
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
||||
<style>
|
||||
|
||||
</style>
|
||||
Reference in New Issue
Block a user