添加地图点击事件

This commit is contained in:
GGJ
2023-12-29 13:22:27 +08:00
parent 24f193c2c7
commit f8768b5f33

View File

@@ -30,14 +30,14 @@ const fetchConfig = async (name: string) => {
const emit = defineEmits(['getRegionByRegionId'])
onMounted(() => {
GetEchar()
GetEchar('中国')
})
const GetEchar = async () => {
const GetEchar = async (name:string) => {
let chartDom = document.getElementById('chartMap')
myCharts.value = echarts.init(chartDom)
echarts.registerMap('china', await fetchConfig('中国')) //注册可用的地图
echarts.registerMap('china', await fetchConfig(name)) //注册可用的地图
var option = {
geo: {
map: 'china',
@@ -116,6 +116,8 @@ const GetEchar = async () => {
// 点击事件
myCharts.value.on('click', e => {
console.log('🚀 ~ file: MyEchartMap.vue:139 ~ GetEchar ~ e:', e.name)
GetEchar(e.name)
emit('getRegionByRegionId', e.data)
myCharts.value.dispatchAction({
type: 'downplay',