打开网页时如何在关闭而不是打开的网络地图中上传地图图例?

How to upload the map legend in the web map closed rather than open when opening the web page?

我有一个通过 ESRI Api 的地图图例。当我打开页面时,它显示为打开

我该怎么做才能让当我打开页面时它像这样关闭

试试这个:

const layerList = new LayerList({
          view: this.mapView,
          style: 'card',
          container: document.createElement('div'),
          listItemCreatedFunction: function(event: any) {
            setTimeout(function() {
              const item = event.item;
 item.panel = {
                  content: 'legend',
                  open: false
                };
             });
          }
        });

参考:esri-widgets-LayerList