@mdi/js在Laravel 9 Vuetify 3上不起作用

ijxebb2r  于 2023-02-05  发布在  其他
关注(0)|答案(1)|浏览(197)

我想在我的Laravel 9 Vuetify 3应用程序中使用@mdi/js。Vuetify 3 documentation告诉我应该做什么。但这对我不起作用。
我的应用程序. 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一起使用吗?

vh0rcniy

vh0rcniy1#

文档指出,您需要向createVuetify调用添加一些内容,才能使svg图标工作。
将调用修改为:

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

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

相关问题