簡體   English   中英

@mdi/js 不適用於 Laravel 9 Vuetify 3

[英]@mdi/js doesn´t work on Laravel 9 Vuetify 3

我想在我的 Laravel 9 Vuetify 3 應用程序中使用@mdi/js Vuetify 3文檔說明了應該做什么。 但這對我不起作用。

我的應用程序.js

import './bootstrap';
import '../css/app.css';

import { createApp, h } from 'vue';
import { createInertiaApp } from '@inertiajs/inertia-vue3';
import { InertiaProgress } from '@inertiajs/progress';
import { resolvePageComponent } from 'laravel-vite-plugin/inertia-helpers';
import { ZiggyVue } from '../../vendor/tightenco/ziggy/dist/vue.m';

const appName = window.document.getElementsByTagName('title')[0]?.innerText || 'Laravel';

// Vuetify
import 'vuetify/styles'
import { createVuetify } from 'vuetify'
import * as components from 'vuetify/components'
import * as directives from 'vuetify/directives'

const vuetify = createVuetify({
  components,
  directives,
})

createInertiaApp({
    title: (title) => `${title} - ${appName}`,
    resolve: (name) => resolvePageComponent(`./Pages/${name}.vue`, import.meta.glob('./Pages/**/*.vue')),
    setup({ el, app, props, plugin }) {
        return createApp({ render: () => h(app, props) })
            .use(plugin)
            .use(ZiggyVue, Ziggy)
            .use(vuetify)
            .mount(el);
    },
});

我的模板:

<script setup>
    import { mdiAccount } from '@mdi/js'
</script>

<template>
    <v-icon :icon="mdiAccount"></v-icon> 
</template>

似乎 vuetify v-icon無法處理 SVG 圖形。 有誰知道我如何將@mdi/jsv-icon和其他 vuetify emits 一起使用?

文檔指出您需要向createVuetify調用添加一些內容才能使 svg 圖標正常工作。

像這樣修改調用:

import { aliases, mdi } from 'vuetify/iconsets/mdi-svg'

const vuetify = createVuetify({
  components,
  directives,
  icons: {
    defaultSet: 'mdi',
    aliases,
    sets: {
      mdi,
    },
  },
})

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM