primevue-mirror/doc/installation/NuxtIntegrationDoc.vue

46 lines
1.3 KiB
Vue
Raw Normal View History

2023-02-28 08:29:30 +00:00
<template>
<DocSectionText v-bind="$attrs">
<p>PrimeVue can easily be used with Nuxt 3 using a custom plugin.</p>
2023-03-08 08:35:24 +00:00
<h3>nuxt.config.js</h3>
2023-07-09 21:13:49 +00:00
<p>Open the nuxt configuration file and add the css dependencies. This step is only required when using styled mode and can be ignored in unstyled mode.</p>
2023-02-28 08:29:30 +00:00
2023-02-28 17:40:48 +00:00
<DocSectionCode :code="code1" hideToggleCode importCode hideCodeSandbox hideStackBlitz />
2023-02-28 08:29:30 +00:00
2023-03-08 08:35:24 +00:00
<h3>primevue.js</h3>
2023-02-28 08:29:30 +00:00
<p>Create a file like <i>primevue.js</i> under the plugins directory for the configuration.</p>
2023-02-28 17:40:48 +00:00
<DocSectionCode :code="code2" hideToggleCode importCode hideCodeSandbox hideStackBlitz />
2023-02-28 08:29:30 +00:00
</DocSectionText>
</template>
<script>
export default {
data() {
return {
code1: {
2023-03-02 12:23:54 +00:00
basic: `export default defineNuxtConfig({
2023-02-28 08:29:30 +00:00
css: [
2023-07-10 08:47:46 +00:00
"primevue/resources/themes/lara-light-blue/theme.css"
2023-02-28 08:29:30 +00:00
],
build: {
transpile: ["primevue"]
}
})`
},
code2: {
2023-03-02 12:23:54 +00:00
basic: `import { defineNuxtPlugin } from "#app";
2023-02-28 08:29:30 +00:00
import PrimeVue from "primevue/config";
import Button from "primevue/button";
export default defineNuxtPlugin((nuxtApp) => {
nuxtApp.vueApp.use(PrimeVue, { ripple: true });
nuxtApp.vueApp.component("Button", Button);
//other components that you need
});`
}
};
}
};
</script>