Skip to content

How to use with Nuxt3? #176

Answered by JustinSchulte
Chippd asked this question in Q&A
Jul 15, 2022 · 1 comments · 1 reply
Discussion options

You must be logged in to vote

May a bit late for the questioner, but I needed this recently and also had some trouble.
So i want to provide my solution:
(Using nuxt@3.0.0 and vue-json-pretty@2.2.3)

You just need to create a .js or .ts file in the /plugins folder:

import VueJsonPretty from 'vue-json-pretty'

export default defineNuxtPlugin((nuxtApp) => {
  nuxtApp.vueApp.component('myJson', VueJsonPretty)
})

Then you only need to add the css at the nuxt.config.ts:

export default defineNuxtConfig({
  // ...
  css: ['vue-json-pretty/lib/styles.css'],
})

So you could just use it by the given name at any template:

<myJson
	:data="someJson"
	v-model:selectedValue="selectedPath"
	:selectOnClickNode="true"
	:showSelectContr…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@Chippd
Comment options

Answer selected by Chippd
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants