修改echart引入方式

This commit is contained in:
MTrunning
2020-07-27 21:06:04 +08:00
parent f032e25cdc
commit dacd429fea
9 changed files with 30 additions and 15 deletions
+1 -1
View File
@@ -21,7 +21,7 @@
| 文件 | 作用/功能 |
| ------------------- | --------------------------------------------------- |
| main.js | 主目录文件,全局引入了引入 vue-awesome |
| main.js | 主目录文件,引入Echart/DataV等文件 |
| utils | 工具函数与 mixins 函数等 |
| views/ index.vue | 项目主结构 |
| views/其余文件 | 界面各个区域组件(按照位置来命名)ajax 接口请求位置 |
@@ -6,7 +6,6 @@
<script>
import echartMixins from "@/utils/resizeMixins";
const echarts = require("echarts");
export default {
data() {
return {
@@ -20,7 +19,7 @@ export default {
methods: {
draw() {
// 基于准备好的dom,初始化echarts实例
this.chart = echarts.init(document.getElementById("bottomLeftChart"));
this.chart = this.$echarts.init(document.getElementById("bottomLeftChart"));
// ----------------------------------------------------------------
let category = [
"市区",
@@ -227,7 +226,7 @@ export default {
itemStyle: {
normal: {
barBorderRadius: 5,
color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
color: new this.$echarts.graphic.LinearGradient(0, 0, 0, 1, [
{ offset: 0, color: "#956FD4" },
{ offset: 1, color: "#3EACE5" }
])
@@ -244,7 +243,7 @@ export default {
itemStyle: {
normal: {
barBorderRadius: 5,
color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
color: new this.$echarts.graphic.LinearGradient(0, 0, 0, 1, [
{ offset: 0, color: "rgba(156,107,211,0.8)" },
{ offset: 0.2, color: "rgba(156,107,211,0.5)" },
{ offset: 1, color: "rgba(156,107,211,0.2)" }
@@ -6,7 +6,7 @@
<script>
import echartMixins from "@/utils/resizeMixins";
const echarts = require("echarts");
export default {
data() {
return {
@@ -26,7 +26,7 @@ export default {
},
draw() {
// 基于准备好的dom,初始化echarts实例
this.chart = echarts.init(document.getElementById("bottomRightChart"));
this.chart = this.$echarts.init(document.getElementById("bottomRightChart"));
// ----------------------------------------------------------------
// 数据
let dateBase = new Date();
@@ -6,7 +6,7 @@
<script>
import echartMixins from "@/utils/resizeMixins";
const echarts = require("echarts");
export default {
data() {
return {
@@ -47,7 +47,7 @@ export default {
methods: {
draw() {
// 基于准备好的dom,初始化echarts实例
this.chart = echarts.init(document.getElementById(this.id));
this.chart = this.$echarts.init(document.getElementById(this.id));
// ----------------------------------------------------------------
let tips = this.tips;
let option = {
@@ -6,7 +6,7 @@
<script>
import echartMixins from "@/utils/resizeMixins";
const echarts = require("echarts");
export default {
data() {
return {
@@ -20,7 +20,7 @@ export default {
methods: {
draw() {
// 基于准备好的dom,初始化echarts实例
this.chart = echarts.init(document.getElementById("centreLeft1Chart"));
this.chart = this.$echarts.init(document.getElementById("centreLeft1Chart"));
// ----------------------------------------------------------------
this.chart.setOption({
@@ -6,7 +6,7 @@
<script>
import echartMixins from "@/utils/resizeMixins";
const echarts = require("echarts");
export default {
data() {
return {
@@ -20,7 +20,7 @@ export default {
methods: {
draw() {
// 基于准备好的dom,初始化echarts实例
this.chart = echarts.init(document.getElementById("centreLeft2Chart"));
this.chart = this.$echarts.init(document.getElementById("centreLeft2Chart"));
// ----------------------------------------------------------------
let option = {
@@ -6,7 +6,7 @@
<script>
import echartMixins from "@/utils/resizeMixins";
const echarts = require("echarts");
export default {
data() {
return {
@@ -20,7 +20,7 @@ export default {
methods: {
draw() {
// 基于准备好的dom,初始化echarts实例
this.chart = echarts.init(document.getElementById("centreRight2Chart1"));
this.chart = this.$echarts.init(document.getElementById("centreRight2Chart1"));
// ----------------------------------------------------------------
let dataBJ = [
[94, 69, 114, 2.08, 73, 39, 22],
+5
View File
@@ -22,6 +22,11 @@ import '@/common/flexible.js';
// 引入全局css
import './assets/scss/style.scss';
//引入echart
import echarts from 'echarts'
Vue.prototype.$echarts = echarts
Vue.config.productionTip = false;
new Vue({
+11
View File
@@ -0,0 +1,11 @@
const path = require('path')
const resolve = dir => {
return path.join(__dirname, dir)
}
module.exports = {
publicPath: './',
chainWebpack: config => {
config.resolve.alias
.set('_c', resolve('src/components')) // key,value自行定义,比如.set('@@', resolve('src/components'))
},
}