Open
Description
I want use it in vue with its directive with hightlightjs, how to use it?
Vue.directive('highlightjs', {
deep: true,
bind: function(el, binding) {
// on first bind, highlight all targets
let targets = el.querySelectorAll('code')
targets.forEach((target) => {
// if a value is directly assigned to the directive, use this
// instead of the element content.
if (binding.value) {
target.textContent = binding.value
console.log(target)
}
hljs.highlightBlock(target)
// hljs.lineNumbersBlock(target)
})
},
componentUpdated: function(el, binding) {
// after an update, re-fill the content and then highlight
let targets = el.querySelectorAll('code')
targets.forEach((target) => {
if (binding.value) {
target.textContent = binding.value
// hljs.initLineNumbersOnLoad();
hljs.highlightBlock(target)
// hljs.lineNumbersBlock(target)
}
})
}
})