docs(vue): add vue-router in installation sections

Related to #2764
This commit is contained in:
Benjamin Canac
2025-01-10 13:06:59 +01:00
parent 85b8553893
commit 046785359e
3 changed files with 32 additions and 4 deletions

View File

@@ -74,11 +74,18 @@ export default defineConfig({
```ts [main.ts]
import { createApp } from 'vue'
import { createRouter, createWebHistory } from 'vue-router'
import ui from '@nuxt/ui/vue-plugin'
import App from './App.vue'
const app = createApp(App)
const router = createRouter({
routes: [],
history: createWebHistory()
})
app.use(router)
app.use(ui)
app.mount('#app')

View File

@@ -73,13 +73,20 @@ components.d.ts
#### Use the Nuxt UI Vue plugin in your `main.ts`
```ts [main.ts]{2,7}
```ts [main.ts]{3,14}
import { createApp } from 'vue'
import { createRouter, createWebHistory } from 'vue-router'
import ui from '@nuxt/ui/vue-plugin'
import App from './App.vue'
const app = createApp(App)
const router = createRouter({
routes: [],
history: createWebHistory()
})
app.use(router)
app.use(ui)
app.mount('#app')
@@ -99,11 +106,18 @@ Import the CSS file in your `main.ts`.
import './assets/main.css'
import { createApp } from 'vue'
import { createRouter, createWebHistory } from 'vue-router'
import ui from '@nuxt/ui/vue-plugin'
import App from './App.vue'
const app = createApp(App)
const router = createRouter({
routes: [],
history: createWebHistory()
})
app.use(router)
app.use(ui)
app.mount('#app')

View File

@@ -93,12 +93,20 @@ bun add vue-i18n@10
#### Use the Vue I18n plugin in your `main.ts`
```ts [main.ts]{2,6-18,22}
```ts [main.ts]{3,14-26,29}
import { createApp } from 'vue'
import { createRouter, createWebHistory } from 'vue-router'
import { createI18n } from 'vue-i18n'
import ui from '@nuxt/ui/vue-plugin'
import App from './App.vue'
const app = createApp(App)
const router = createRouter({
routes: [],
history: createWebHistory()
})
const i18n = createI18n({
legacy: false,
locale: 'en',
@@ -113,8 +121,7 @@ const i18n = createI18n({
}
})
const app = createApp(App)
app.use(router)
app.use(i18n)
app.use(ui)