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