init: api-gateway v2.4.0(Agnes/b.ai/火山方舟 三家供应商网关)
This commit is contained in:
commit
f136c9ee81
91 files changed
+24653
No files matched your search
@@ -0,0 +1,40 @@
|
||||
<template>
|
||||
<div ref="el" class="echart" :style="{ height: height }"></div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { onMounted, onUnmounted, ref, watch } from 'vue'
|
||||
import { echarts, type EChartsCoreOption } from '../lib/echarts'
|
||||
|
||||
const props = defineProps<{
|
||||
option: EChartsCoreOption
|
||||
height?: string
|
||||
}>()
|
||||
|
||||
const el = ref<HTMLElement>()
|
||||
let chart: any = null
|
||||
let ro: ResizeObserver | null = null
|
||||
|
||||
function setOpt() {
|
||||
if (chart) chart.setOption(props.option || {}, true)
|
||||
}
|
||||
function resize() { if (chart) chart.resize() }
|
||||
|
||||
onMounted(() => {
|
||||
chart = echarts.init(el.value!)
|
||||
setOpt()
|
||||
if (typeof ResizeObserver !== 'undefined') {
|
||||
ro = new ResizeObserver(resize)
|
||||
ro.observe(el.value!)
|
||||
}
|
||||
})
|
||||
watch(() => props.option, setOpt, { deep: true })
|
||||
onUnmounted(() => {
|
||||
if (ro) ro.disconnect()
|
||||
if (chart) { chart.dispose(); chart = null }
|
||||
})
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.echart { width: 100%; }
|
||||
</style>
|
||||
Reference in new issue
Block a user