【发布时间】:2018-12-09 08:16:25
【问题描述】:
我在我的应用程序中使用了很多图表,我想尽可能地处理来自 vuex 商店的所有图表颜色。我用下面的代码来做这个。
store.js
import Vue from 'vue'
import Vuex from 'vuex'
// modules
import settings from './modules/settings';
Vue.use(Vuex);
export const store = new Vuex.Store({
modules: {
settings
}
})
chart-config.js
/**
* Change all chart colors
*/
import { store } from "../store/store";
const { primary, warning, error, info, success } = store.getters.chartColors;
export const ChartConfig = {
color: {
'primary': primary,
'warning': warning,
'danger': error,
'success': success,
'info': info,
'white': '#fff',
'lightGrey': '#E8ECEE'
},
lineChartAxesColor: '#E9ECEF',
legendFontColor: '#AAAEB3', // only works on react chart js 2
chartGridColor: '#EAEAEA',
axesColor: '#657786',
shadowColor: 'rgba(0,0,0,0.3)'
}
文件夹结构:
src
-components
-constants
--chart-config.js
-store
--store.js
-views
App.vue
main.js
每当我尝试运行 npm run dev 命令时都会遇到此类错误
95% emitting HtmlWebpackPlugin/media/iron/631dbce0-858c-4a8c-bef4-
a01a6a92507f/shubham/work/dev/vue/myapp/node_modules/toposort/index.js:35
throw new Error('Cyclic dependency' + nodeRep)
【问题讨论】: