Skip to content

Commit c534be7

Browse files
committed
Merge branch 'hotfix/fix-585'
2 parents 0d5e1d6 + 8f4f8e6 commit c534be7

File tree

4 files changed

+20
-21
lines changed

4 files changed

+20
-21
lines changed

vue-examples/package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,12 @@
99
},
1010
"dependencies": {
1111
"core-js": "^3.30.2",
12+
"highlight.js": "^11.8.0",
1213
"jquery": "^3.7.0",
1314
"multiple-select": "^1.6.0",
14-
"vue": "^2.6.10",
15-
"vue-highlight.js": "^3.1.0",
16-
"vue-router": "^3.0.6",
17-
"vuex": "^3.0.1"
15+
"vue": "^2.7.14",
16+
"vue-router": "^3.6.5",
17+
"vuex": "^3.6.2"
1818
},
1919
"devDependencies": {
2020
"@vue/cli-plugin-babel": "^4.0.4",

vue-examples/src/main.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import Vue from 'vue'
22
import App from './App.vue'
33
import './plugins/select'
4-
import './plugins/highlight'
54
import router from './router'
65

76
Vue.config.productionTip = false

vue-examples/src/plugins/highlight.js

Lines changed: 0 additions & 10 deletions
This file was deleted.

vue-examples/src/views/Main.vue

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,17 +25,15 @@
2525
<div v-if="!isSource">
2626
<component :is="componentLoader" />
2727
</div>
28-
<highlight-code
29-
v-else
30-
lang="vue"
31-
>
32-
{{ componentSource }}
33-
</highlight-code>
28+
<pre v-else><code class="html">{{ componentSource }}</code></pre>
3429
</div>
3530
</div>
3631
</template>
3732

3833
<script>
34+
import hljs from 'highlight.js/lib/core'
35+
import xml from 'highlight.js/lib/languages/xml'
36+
import 'highlight.js/styles/default.css'
3937
import registry from '@/registry'
4038
import Ads from '@/components/Ads'
4139
import MS from '@/assets/MS'
@@ -87,14 +85,26 @@ export default {
8785
},
8886
isSource () {
8987
this.updateAds()
88+
this.updateHighlight()
9089
}
9190
},
91+
mounted () {
92+
hljs.registerLanguage('xml', xml)
93+
this.updateHighlight()
94+
},
9295
methods: {
9396
updateAds () {
9497
this.hideAds = true
9598
setTimeout(() => {
9699
this.hideAds = false
97100
}, 500)
101+
},
102+
updateHighlight () {
103+
this.$nextTick(() => {
104+
document.querySelectorAll('pre code').forEach(el => {
105+
hljs.highlightElement(el)
106+
})
107+
})
98108
}
99109
}
100110
}

0 commit comments

Comments
 (0)