fix: echart报错

This commit is contained in:
chenjianxing 2021-10-27 11:02:12 +08:00 committed by jianxing
parent 5f0d4a243f
commit e93b57e062
4 changed files with 24 additions and 4 deletions

View File

@ -1,8 +1,9 @@
<template> <template>
<chart <chart
:style="{'height': height + 'px'}"
class="ms-chart" class="ms-chart"
:init-options="defaultInitOptions" :init-options="defaultInitOptions"
:options="options" :option="options"
:theme="theme" :theme="theme"
:group="group" :group="group"
@click="onClick" @click="onClick"
@ -22,7 +23,13 @@ export default {
group: String, group: String,
autoresize: Boolean, autoresize: Boolean,
watchShallow: Boolean, watchShallow: Boolean,
manualUpdate: Boolean manualUpdate: Boolean,
height: {
type: Number,
default() {
return 400
}
}
}, },
data() { data() {
return { return {

View File

@ -1,6 +1,6 @@
<template> <template>
<div> <div>
<ms-chart v-if="visible && data.length > 0" :options="options"/> <ms-chart v-if="visible && data.length > 0" :options="options" :height="height"/>
<div v-if="visible && data.length <= 0" style="height: 300px"> <div v-if="visible && data.length <= 0" style="height: 300px">
</div> </div>
@ -66,6 +66,12 @@ export default {
return [] return []
} }
}, },
height: {
type: Number,
default() {
return 400
}
}
}, },
watch: { watch: {
data() { data() {

View File

@ -1,7 +1,7 @@
<template> <template>
<div> <div>
<ms-chart :options="options" @onClick="onClick"> <ms-chart :options="options" @onClick="onClick" :height="height">
</ms-chart> </ms-chart>
</div> </div>
@ -74,6 +74,12 @@ export default {
type: String, type: String,
default: '' default: ''
}, },
height: {
type: Number,
default() {
return 400
}
},
data: { data: {
type: Array, type: Array,
default() { default() {

View File

@ -9,6 +9,7 @@ import 'echarts/lib/component/toolbox';
import 'echarts/lib/component/dataZoom'; import 'echarts/lib/component/dataZoom';
import 'echarts/lib/component/legend'; import 'echarts/lib/component/legend';
import 'zrender/lib/svg/svg' import 'zrender/lib/svg/svg'
import 'echarts/lib/component/grid'
export default { export default {
install(Vue) { install(Vue) {