【问题标题】:throw new Error('Cyclic dependency' + nodeRep)throw new Error('循环依赖' + nodeRep)
【发布时间】: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)

【问题讨论】:

    标签: vue.js vuex


    【解决方案1】:

    2018 年 7 月 31 日更新

    几天前,我在使用@vue/cli (Vue CLI 3) 创建的 vue 应用程序时遇到了同样的问题。但是最近they fixed it

    旧答案

    我的解决方案是在项目根目录(package.json 旁边)中创建vue.config.js resets chunksSortMode of the package html-webpack-plugin

    vue.config.js

    module.exports = {
      chainWebpack: config => {
        config
          .plugin('html')
          .tap(args => {
            args[0].chunksSortMode = 'none'
    
            return args
          })
      }
    }
    

    【讨论】:

    • vue 页面选项出现错误“chunksSortMode of undefined”!这该怎么办!!?参数为空
    猜你喜欢
    • 2020-08-03
    • 2018-02-27
    • 1970-01-01
    • 2012-02-27
    • 2019-04-15
    • 1970-01-01
    相关资源
    最近更新 更多