Is this plugin must be registered globally?
See original GitHub issuei read the docs for vue2, and can’t find the locally regisered example, only the globally registered example. so i try it out, and failed. So is this plugin can only be registered globablly, or am i miss something?
i read the issue #1 , it seems related, but i’m using one single version of highlightjs 10.7.2, so i’m not quite clear whether or not this plugin supports locally register.
thanks.
NODE_MODULES
+---@highlightjs
| \---vue-plugin
| +---dist
| \---src
| \---lib
+---highlight.js
| +---lib
| | \---languages
| +---scss
| +---styles
| \---types
GOOD version (Globally registered):
<template>
<div>
<highlightjs language="javascript" code="var x = 5;" />
</div>
</template>
<script>
import Vue from 'vue'
import hljs from 'highlight.js/lib/core'
import javascript from 'highlight.js/lib/languages/javascript'
import 'highlight.js/styles/a11y-dark.css'
import hljsVuePlugin from '@highlightjs/vue-plugin'
hljs.registerLanguage('javascript', javascript)
Vue.use(hljsVuePlugin)
export default {
components: {}
}
</script>
BAD version (Registered in single file component):
<template>
<div>
<highlightjs language="javascript" code="var x = 5;" />
</div>
</template>
<script>
import Vue from 'vue'
import hljs from 'highlight.js/lib/core'
import javascript from 'highlight.js/lib/languages/javascript'
import 'highlight.js/styles/a11y-dark.css'
import hljsVuePlugin from '@highlightjs/vue-plugin'
hljs.registerLanguage('javascript', javascript)
// Vue.use(hljsVuePlugin)
export default {
components: { hljsVuePlugin }
}
</script>
errors in chrome console:
vue.runtime.esm.js?2b0e:619 [Vue warn]: Unknown custom element: <highlightjs> - did you register the component correctly? For recursive components, make sure to provide the "name" option.
found in
---> <TestTarget> at src/views/WebView/SourceCodeViewer.vue
<TestPage> at src/pages/TestPage.vue
<App> at src/App.vue
<Root>
if i give a name,the error message change, but still cannot render the ‘var x = 5’
export default {
components: { 'highlightjs': hljsVuePlugin }
}
vue.runtime.esm.js?2b0e:619 [Vue warn]: Failed to mount component: template or render function not defined.
found in
---> <Highlightjs>
<TestTarget> at src/views/WebView/SourceCodeViewer.vue
<TestPage> at src/pages/TestPage.vue
<App> at src/App.vue
<Root>
Issue Analytics
- State:
- Created 2 years ago
- Comments:6 (4 by maintainers)
Top Results From Across the Web
ChartJS unable to register global plugin - Stack Overflow
Plugins must define a unique id in order to be configurable. So i just added the id in my code. Chart.register({ id: 'no_data_label' ......
Read more >Do not register plugin globally when using module import #377
The actual workaround I found is to unregister the plugin right after the import: import chartJsPluginZoom from 'chartjs-plugin-zoom'; Chart.
Read more >Plugins | Chart.js
Plugins can be registered globally to be applied on all charts (a.k.a. ... Plugins must define a unique id in order to be...
Read more >Getting Started - chartjs-plugin-datalabels
Since version 1.x, this plugin no longer registers itself automatically. It must be manually registered either globally or locally (see #42 ...
Read more >How can I register a global action filter from my plugin in ...
Hi timmit, First you need to implement this interface in your plugin INopStartup and set the order to be some number bigger than...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
The vue2 version exports
component
also, though Vue 3 version does not. Perhaps that would work?Would mind resolving maybe? 🙃