首页 > 解决方案 > 如何从控制台 chrome 复制地图对象?

问题描述

我想从 chrome 中的控制台复制以角度创建的地图:

Map(7) {1 => {…}, 2 => {…}, 3 => {…}, 4 => {…}, 5 => {…}, …}

我无法完整复制此地图!

标签: javascriptangulargoogle-chromeconsole.log

解决方案


我假设你想复制地图条目,你可以使用 chrome 的copy命令。

// create large amount of entries as an example
const entries = Array(100).fill(null).map((_, i) => [i, i]);

const map = new Map(entries);

// this would copy the map's entries to clipboard
copy(Array.from(map));

推荐阅读