【发布时间】:2023-04-05 21:02:02
【问题描述】:
使用 Vuetify 2 和 Storybook 6(来源 https://github.com/lydonchandra/vuetify2storybook6)
组件渲染正常,但在第一次渲染组件时不断收到此错误 TypeError,因为 vm.$vuetify.icons 未定义。
不确定我错过了哪个 storybook-vuetify 初始化桥?
TypeError: Cannot read property 'component' of undefined
at remapInternalIcon (vuetify.js:44048)
at VueComponent.getIcon (vuetify.js:16881)
at Proxy.render (vuetify.js:17009)
at VueComponent.Vue._render (vue.esm.js:3557)
at VueComponent.updateComponent (vue.esm.js:4075)
at Watcher.get (vue.esm.js:4488)
at new Watcher (vue.esm.js:4477)
function remapInternalIcon(vm, iconName) {
// Look for custom component in the configuration
var component = vm.$vuetify.icons.component; // <-- issue here when rendering for first time
if (iconName.startsWith('$')) {
// Get the target icon name
src/plugins/vuetify.ts
import Vue from "vue";
import Vuetify from "vuetify/lib";
import { UserVuetifyPreset } from "vuetify";
Vue.use(Vuetify);
export const options: UserVuetifyPreset = {
icons: {
iconfont: "mdiSvg"
}
};
export default new Vuetify(options);
【问题讨论】:
标签: vuejs2 vuetify.js storybook