How does this work
- Create a custom plugin and put it in
plugins(plugins_vue-chartjs.js). - Add the plugin to
nuxt.config.jsand setssrtofalseto prevent the server to initialize it. - You can use the component now just like other Vue-components. The only problem is that you get errors because the DOM-tree is out of sync (because the server misses the component)
- As
mounted()is only called by the client (browser) we're using this to render the component only in the browser. AddshowLine: falseto data (so the server will not render it) and turn it totrueinmounted(). - Use
v-ifto render the component. Now it won't be rendered on the server side, but it will show up in de browser.
This way also works with other Vue.js plugins
Used in this example:
npm install vue-chartjs --save
npm install chart.js --save
hello,
thanks for that, It's actually doest work unfortunately for my Nuxt project, i got this error :
Uncaught TypeError: WEBPACK_IMPORTED_MODULE_1_vue_chartjs.a.extend is not a function
I simply pasted your code here,,
thanks,