javascript - 无法将 Vuetify 项目更新为 vuetify 2.0.0-beta5

标签 javascript vue.js vuetify.js webpack-encore

vuetify LTS 更新时遇到问题至 vuetify 2.0.0-beta.5 .

在一切正常之前,vuetify 样式从 app.scss 加载

错误:

[Vue warn]: Error in getter for watcher "isDark": "TypeError: Cannot read property 'dark' of undefined"

TypeError: Cannot read property 'dark' of undefined

[Vue warn]: Error in render: "TypeError: Cannot read property 'dark' of undefined"

我已经卸载了 vuetify,然后像这样安装并更新到测试版 https://stackoverflow.com/a/49250912

package.json

{
  "devDependencies": {
    "@fortawesome/fontawesome-free": "^5.9.0",
    "@mdi/font": "^3.7.95",
    "@symfony/webpack-encore": "^0.22.0",
    "axios": "^0.19.0",
    "chart.js": "^2.8.0",
    "less": "^3.9.0",
    "less-loader": "^4.1.0",
    "material-design-icons-iconfont": "^5.0.1",
    "node-sass": "^4.11.0",
    "sass-loader": "^7.1.0",
    "vue": "^2.6.8",
    "vue-loader": "^15.7.0",
    "vue-template-compiler": "^2.6.8",
    "webpack-dev-server": "^3.2.1",
    "webpack-notifier": "^1.6.0"
  },
  "license": "UNLICENSED",
  "private": true,
  "scripts": {
    "dev-server": "encore dev-server --hot --disable-host-check --host 174.28.1.5 --public 174.28.1.5:8080",
    "dev": "encore dev",
    "watch": "encore dev --watch",
    "build": "encore production --progress"
  },
  "dependencies": {
    "apexcharts": "^3.8.1",
    "chart.js": "^2.8.0",
    "core-js": "^3.1.4",
    "vue-apexcharts": "^1.4.0",
    "vue-google-signin-button": "^1.0.4",
    "vue-telegram-login": "^2.1.0",
    "vuetify": "^1.5.14",
    "vuex": "^3.1.1"
  }
}

webpack.config.js

var path = require('path');
var Encore = require('@symfony/webpack-encore');

Encore
    .setOutputPath('public/build/')
    .setPublicPath('/build')
    .addStyleEntry('styles', './assets/css/app.scss')
    .enableSassLoader()
    .enableVueLoader()
    .addEntry('landing', './assets/js/modules/landing/main.js')
    .addEntry('main', './assets/js/modules/dashboard/main/main.js')
    .addEntry('main-m', './assets/js/modules/dashboard_m/main.js')
    .enableBuildNotifications()
    .enableSourceMaps(!Encore.isProduction())
    .cleanupOutputBeforeBuild()
    .enableVersioning(Encore.isProduction())
    .enableSingleRuntimeChunk()
;
main_config = Encore.getWebpackConfig();
main_config.resolve.alias["~"] = path.resolve(__dirname, 'assets/js');
module.exports = main_config;

ma​​in.js

import Vue from 'vue';
import Vuetify from 'vuetify';
import VueApexCharts from 'vue-apexcharts';
import Dashboard from './Dashboard';
import store from './store/index'

Vue.component('current-session', () => import('./DashboardModule'));

Vue.use(Vuetify, {
    iconfont: 'fa'
});
Vue.use(VueApexCharts);

Vue.component('apexchart', VueApexCharts);

require('apexcharts');
require('vue-apexcharts');

new Vue({
    el: '#dashboard-m',
    store,
    components: {Dashboard},
    render: a => a(Dashboard),
});

app.scss

@import "~@fortawesome/fontawesome-free/css/all.min.css";

已尝试通过添加 vuetify-loader 来修复它,并不是说我已经正确地完成了它,但它仍然无法正常工作,这里是我的更新:

webpack.config.js

const VuetifyLoaderPlugin = require('vuetify-loader/lib/plugin');
// .enableSassLoader() - turned off it
.addLoader({
    test: /\.s(c|a)ss$/,
    use: [
        'style-loader',
        'vue-style-loader',
        'css-loader',
        {
            loader: 'sass-loader',
            options: {
                implementation: require('sass'),
                fiber: require('fibers'),
                indentedSyntax: true, // optional
            }
        }
    ]
})

node-sass package.json 中删除

所以当一个添加了这个

<v-app id="inspire" :dark="false">

我已经用 <v-app> 解决了我的问题标签,但得到了另一个组件不加载默认 Prop 像这样:

[Vue warn]: Error in mounted hook: "TypeError: Cannot read property 'register' of undefined"

或者这个:

[Vue warn]: Error in getter for watcher "showOverlay": "TypeError: Cannot read property 'width' of undefined"

最佳答案

感谢 jacek(Vuetify 核心团队) 这是将 vuetify 添加到 Vue 的正确方法:

// v2.0
import Vue from 'vue'
import Vuetify from 'vuetify'
import 'vuetify/dist/vuetify.min.css'

const opts = { ... }
Vue.use(Vuetify)

new Vue({
  vuetify: new Vuetify(opts)
}).$mount('#app')

关于javascript - 无法将 Vuetify 项目更新为 vuetify 2.0.0-beta5,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56908698/

相关文章:

javascript - javascript 属性如何添加到对象并在对象上查找?

javascript - jQuery PageSlide : . 点击时的 css 函数

javascript - 无法从 Parse Cloud 函数中的 httpRequest 检索结果

javascript - Laravel 5.1 和 Vue.js - 21678 未捕获( promise )TypeError : Cannot read property 'data' of null

javascript - Vue.js 中的符号 ' 不适用于我的模板

javascript - v-autocomplete on-select on-remove in vuetify

Javascript 投票 acts_as_votable

vue.js - Vue 计算 setter 不适用于复选框?

javascript - 在 Vue 中以编程方式更改自动完成所选项目

vuetify.js - V-data-table 通过 v-slot 控制扩展项 :body