yangyanggu / vue-amap

高德地图封装 for vue2 vue3.0
https://vue-amap.guyixi.cn/
MIT License
287 stars 17 forks source link

el-amap-elastic-marker中的styles > label.content失去响应 #69

Closed codingtalk closed 2 months ago

codingtalk commented 12 months ago

使用版本

请填写使用版本:2.0.24 vue:3.3.9

问题描述

使用el-amap-elastic-marker组件,传递属性:styles="item.styles", 如果直接改变数组里面的的label.content内容,地图内容不更新 convertedPoints[i].styles[0].label.content = eleToMount.innerHTML

codingtalk commented 12 months ago

在playground也可以复现 https://amap-run.guyixi.cn/#eyJzcmMvQXBwLnZ1ZSI6Ijx0ZW1wbGF0ZT5cbiAgPGRpdiBjbGFzcz1cIm1hcC1wYWdlLWNvbnRhaW5lclwiPlxuICAgIDxlbC1hbWFwXG4gICAgICA6Y2VudGVyPVwiY2VudGVyXCJcbiAgICAgIDp6b29tPVwiem9vbVwiXG4gICAgPlxuICAgICAgPGVsLWFtYXAtZWxhc3RpYy1tYXJrZXJcbiAgICAgICAgOnBvc2l0aW9uPVwiY29tcG9uZW50TWFya2VyLnBvc2l0aW9uXCJcbiAgICAgICAgdGl0bGU9XCLmoIflj7dcIlxuICAgICAgICA6dmlzaWJsZT1cImNvbXBvbmVudE1hcmtlci52aXNpYmxlXCJcbiAgICAgICAgOmRyYWdnYWJsZT1cImNvbXBvbmVudE1hcmtlci5kcmFnZ2FibGVcIlxuICAgICAgICA6em9vbS1zdHlsZS1tYXBwaW5nPVwiY29tcG9uZW50TWFya2VyLnpvb21TdHlsZU1hcHBpbmdcIlxuICAgICAgICA6c3R5bGVzPVwiY29tcG9uZW50TWFya2VyLnN0eWxlc1wiXG4gICAgICAgIEBpbml0PVwibWFya2VySW5pdFwiXG4gICAgICAgIEBjbGljaz1cImNsaWNrTWFya2VyXCJcbiAgICAgIC8+XG4gICAgPC9lbC1hbWFwPlxuICA8L2Rpdj5cbiAgPGRpdiBjbGFzcz1cInRvb2xiYXJcIj5cbiAgICA8YnV0dG9uIEBjbGljaz1cImNoYW5nZVZp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hcC92dWUtYW1hcC1sb2NhL2dsb2JhbC5kLnRzXCIsXCJAdnVlbWFwL3Z1ZS1hbWFwLWV4dHJhL2dsb2JhbC5kLnRzXCJdLFxuICAgIFwiYWxsb3dJbXBvcnRpbmdUc0V4dGVuc2lvbnNcIjogdHJ1ZSxcbiAgICBcImFsbG93SnNcIjogdHJ1ZSxcbiAgICBcImNoZWNrSnNcIjogdHJ1ZVxuICB9LFxuICBcImluY2x1ZGVcIjogW1widHlwaW5ncy8qKi8qXCJdLFxuICBcInZ1ZUNvbXBpbGVyT3B0aW9uc1wiOiB7XG4gICAgXCJ0YXJnZXRcIjogMy4zXG4gIH1cbn1cbiIsInR5cGluZ3MvZ2xiYWwuZC50cyI6ImRlY2xhcmUgY29uc3QgQU1hcDogYW55XG5kZWNsYXJlIGNvbnN0IExvY2E6IGFueVxuIiwiX28iOnt9fQ==

yangyanggu commented 12 months ago

我确认了下,这个是文档有错误,高德官方styles字段不支持修改,所以这个属于静态属性

codingtalk commented 12 months ago

我确认了下,这个是文档有错误,高德官方styles字段不支持修改,所以这个属于静态属性

这个我记得之前的版本是可以的,项目正常更新,最近因为我升级了版本(vue, @vuemap/vue-amap),就不行

yangyanggu commented 12 months ago

https://lbs.amap.com/api/javascript-api-v2/documentation#elasticmarker 你可以看下高德文档,组件库内部对属性的set方法处理是直接识别高德对象的,如果有对应的set方法会自动增加watch进行处理,目前高德文档里就不存在修改styles的能力

codingtalk commented 12 months ago

https://lbs.amap.com/api/javascript-api-v2/documentation#marker setLabel这个方法是不是可以避免重新绘制marker的前提下更新content? -- thanks for your contribution to the opensource 👍

yangyanggu commented 12 months ago

你如果使用el-amap-marker的话可以直接 slot的方式去处理,slot走的是vue的渲染模式,性能肯定更好一些

codingtalk commented 12 months ago

ok, 我试试这个组件, 谢谢