尝试升级到 vuetify 2.0 时出错 [英] getting error when trying to upgrade to vuetify 2.0

查看:28
本文介绍了尝试升级到 vuetify 2.0 时出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

好的,所以我第二次尝试迁移到目前为止它完全失败了似乎没有检测到 vuetify,不幸的是我无法分享我的完整存储库,因为它与工作相关,但会描述步骤并分享相关代码.项目是使用 vue-cli 3.3.0 创建的,其中包含一个用于环境变量的 vue.config.js 文件.1) npm 卸载 vuetify2)vue 添加 vuetify3) npm 运行服务我的网站无法加载,并且出现此错误(添加代码):

Ok so I am trying for the second time to migrate thus far it has been a complete failure it seems that vuetify is not detected, unfortunately I cannot share my full repo since it is work related, but will describe steps and share relevant code. Project was created with vue-cli 3.3.0 with a vue.config.js file for environment variables. 1) npm uninstall vuetify 2)vue add vuetify 3)npm run serve my site does not load and I get this error (adding code):

//vue.config.js
module.exports = {
    chainWebpack: (config) => {
        config.plugin('define')
            .tap(([options, ...args]) => {

                let env = options['process.env'].VUE_APP_ENV.replace(/"/g,'');
                let envMdl = require('./build/' + env.toString() + '.js');

                // replace all current by VUE concrente ones to be passed to the app
                const processEnv = Object.assign({}, options['process.env'])
                Object.keys(envMdl).forEach(function (k) {
                    processEnv['VUE_APP_' + k] = envMdl[k];
                });

                const ret = Object.assign({}, options, {'process.env': processEnv});

                return [
                    ret,
                    ...args
                ]
            })
    }
}

//vuetify.js

//vuetify.js

import Vue from 'vue'
import Vuetify from 'vuetify/lib'

Vue.use(Vuetify)

export default new Vuetify({
  icons: {
    iconfont: 'mdiSvg',
  },
})

//main.js

import vuetify from './plugins/vuetify'
...
new Vue({
                vuetify,
                router,
                store,
                i18n,
                render: h => h(App),
...

错误信息(和截图):Uncaught TypeError: _lib.default is not a constructor在 eval (vuetify.js?402c:6)

推荐答案

主要问题是 Vuetify v1 在 Stylus 预处理器下工作,而在 v2 中它在 SASS 预处理器下工作,我个人不建议迁移到 v2,如果如果它有自定义的 Vuetify 组件,那就太先进了,甚至更糟.

The main problem is that Vuetify v1 works under the Stylus preprocessor, and in v2 it works under the SASS preprocessor, and I personally do not recommend migrating to v2 if it is too advanced and even worse if it has custom Vuetify components.

这篇关于尝试升级到 vuetify 2.0 时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆