添加地图点击事件
This commit is contained in:
@@ -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',
|
||||
|
||||
Reference in New Issue
Block a user