来自数据的CircleMarker多类名

我想从数据中添加3个classname到CircleMarker,但是我只能添加1个classname。这里可能是代码

const xxx = [
{ name: 'myname',website: 'mywebsite',city: 'London'}
{ name: 'yourname',website: 'yourwebsite',city: 'Dublin'}

for (let i = 0; i < xxx.length; i++) {

  let nam= xxx[i].name
  let web= xxx[i].website
  let cit= xxx[i].city

       Object.defineProperty(xxx[i],'objectcircle',{
            value: new L.CircleMarker(xxx[i].geometry,{
                radius: 5,fillColor: "black",width: 0.5,stroke: "black",color: '#FFFFF',fillOpacity: 0.5,classname: nam web cit
            })
        });
let circle = xxx[i].objectcircle
circle.addTo(map)
zhouhsmp3 回答:来自数据的CircleMarker多类名

我明白了:

Object.defineProperty(xxx[i],'objectcircle',{
            value: new L.CircleMarker(xxx[i].geometry,{
                radius: 5,fillColor: "black",width: 0.5,stroke: "black",color: '#FFFFF',fillOpacity: 0.5,className: `${nam} ${web} ${cit}`
            })
        });
本文链接:https://www.f2er.com/3101323.html

大家都在问