gluons / vue-highlight.js

📜 Highlight.js syntax highlighter component for Vue.
https://git.io/vue-highlight.js
MIT License
208 stars 24 forks source link

hljs.highlight is not a function #29

Open dbruning opened 4 years ago

dbruning commented 4 years ago

I got this error (hljs.highlight is not a function) and it turned out to be because highlight.js revved to 10.1.1, and somewhere along the line it's now incompatible with vue-highlight.js

Workaround is to set the highlight.js version to ^9.11.0 in package.json.

Might want to revisit the decision not to Move highlight.js from peerDependencies into dependencies

issue-label-bot[bot] commented 4 years ago

Issue-Label Bot is automatically applying the label bug to this issue, with a confidence of 0.76. Please mark this comment with :thumbsup: or :thumbsdown: to give our bot feedback!

Links: app homepage, dashboard and code for this bot.

bramchi commented 3 years ago

I had a similar error message:

registerLanguage is not a function

Downgrading highlight.js to ^9.11.0 fixed that.

Thanks for the pointer!

baijifeilong commented 3 years ago

highlightjs support Vue officially now.

import hljs from "highlight.js"
import "highlight.js/styles/github.css"
Vue.use(hljs.vuePlugin);
<highlightjs language='javascript' code="var x = 5;" />
gluons commented 3 years ago

Version 4 was released.
You can try it via npm install vue-highlight.js@next.