英文:
Unable to load custom component icons in Vuetify3 (Vue3)
问题
这是我们正在努力解决的代码片段,但实际上它生成了一个错误。错误消息说:“找不到别名图标 $vuetify.icons.gaming”。
import { createVuetify } from 'vuetify';
import * as components from 'vuetify/components';
import * as directives from 'vuetify/directives';
import gamingIcon from 'assets/custom-icons/sector/gaming.vue';
const opts = {
icons: {
// iconfont: 'mdi',
defaultSet: 'mdi',
aliases,
sets: {
gaming: {
component: gamingIcon,
},
},
},
};
const vuetify = createVuetify({
opts,
components,
directives,
});
export default vuetify;
任何帮助将不胜感激。
英文:
Here is the code snippet that we are trying to work on but its actually generating an error. The error message says
"Could not find aliased icon " $vuetify.icons.gaming "
import { createVuetify } from 'vuetify';
import * as components from 'vuetify/components';
import * as directives from 'vuetify/directives';
import gamingIcon from 'assets/custom-icons/sector/gaming.vue';
const opts = {
icons: {
// iconfont: 'mdi',
defaultSet: 'mdi',
aliases,
sets: {
gaming: {
component: gamingIcon,
},
},
},
};
const vuetify = createVuetify({
opts,
components,
directives,
});
export default vuetify;
Any help would be greatly appreciated.
答案1
得分: 1
添加自定义图标作为别名
import { createVuetify } from 'vuetify';
import * as components from 'vuetify/components';
import * as directives from 'vuetify/directives';
import { aliases, mdi } from "vuetify/iconsets/mdi";
import gamingIcon from 'assets/custom-icons/sector/gaming.vue';
const aliasesCustom = {
...aliases,
gamingIcon,
};
const opts = {
icons: {
defaultSet: "mdi",
aliases: {
...aliasesCustom,
},
sets: {
mdi,
},
},
};
const vuetify = createVuetify({
opts,
components,
directives,
});
export default vuetify;
SFC usage
<v-icon>$gamingIcon</v-icon>
<details>
<summary>英文:</summary>
Add your custom icon as an alias
```js
import { createVuetify } from 'vuetify';
import * as components from 'vuetify/components';
import * as directives from 'vuetify/directives';
import { aliases, mdi } from "vuetify/iconsets/mdi";
import gamingIcon from 'assets/custom-icons/sector/gaming.vue';
const aliasesCustom = {
...aliases,
gamingIcon,
};
const opts = {
icons: {
defaultSet: "mdi",
aliases: {
...aliasesCustom,
},
sets: {
mdi,
},
},
};
const vuetify = createVuetify({
opts,
components,
directives,
});
export default vuetify;
SFC usage
<v-icon>$gamingIcon</v-icon>
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论