【发布时间】:2019-11-16 10:06:08
【问题描述】:
从vuetify LTS 更新到vuetify 2.0.0-beta.5 时出现问题。
在一切正常之前,vuetify 样式是从 app.scss 加载的
错误:
[Vue 警告]:观察者“isDark”的 getter 错误:“TypeError:不能 读取未定义的“黑暗”属性”
TypeError: 无法读取未定义的属性 'dark'
[Vue 警告]:渲染错误:“TypeError:无法读取属性‘dark’ 未定义”
我已经卸载了 vuetify,然后安装并更新到像 https://stackoverflow.com/a/49250912 这样的 beta 版本
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;
main.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
}
}
]
})
从 package.json
中删除node-sass所以当一个添加了这个
<v-app id="inspire" :dark="false">
我已经用<v-app> 标签解决了我的问题,但是得到了另一个组件不加载默认道具
像这样:
[Vue 警告]:挂载钩子错误:“TypeError:无法读取属性 未定义的‘注册’”
或者这个:
[Vue 警告]:观察者“showOverlay”的 getter 错误:“TypeError: 无法读取未定义的属性“宽度”
【问题讨论】:
标签: javascript vue.js vuetify.js webpack-encore