How to fix Uncaught TypeError: Cannot assign to read only property 'data' of object '#<ImageData>'

How to fix Uncaught TypeError: Cannot assign to read only property 'data' of object '#<ImageData>'

我正在尝试将数据添加到我的热图中。 我使用这个库来做到这一点 https://github.com/pa7/heatmap.js + 来自这个的插件。

这是我的导入:

<ltng:require styles='/resource/leafletMarkerCluster/Leaflet.markercluster-1.4.1/dist/MarkerCluster.css, 
                      /resource/leafletMarkerCluster/Leaflet.markercluster-1.4.1/dist/MarkerCluster.Default.css'
              scripts='/resource/leaflet/leaflet.js,/resource/leafletMarkerCluster/Leaflet.markercluster-1.4.1/dist/leaflet.markercluster.js, 
                       /resource/LeafletHeatmapLayer/heatmap.js-develop/build/heatmap.js,
                       /resource/LeafletHeatmapLayer/heatmap.js-develop/plugins/leaflet-heatmap/leaflet-heatmap.js'
              afterScriptsLoaded="{!c.jsLoaded}" />

已定义帐户:

locationsAccounts[i]=helper.heatpoint(account.ShippingLatitude, account.ShippingLongitude,1);

heatpoint: function Person(latitude, longitude, counter) {
  return {
    lat: latitude,
    lng: longitude,
    count: counter
  };
}

var testData = { max: accounts.length,
                 data: locationsAccounts };

heatmapLayer.setData(testData);

Heatmap属于L.control.layers是overlay之一。

更新我看到在调试时我在 addData 和 setData 方法中遇到了这个问题: 异常:TypeError:'caller'、'callee' 和 'arguments' 属性可能无法在严格模式函数或在 Function.invokeGetter 调用它们的参数对象上访问

我假设您的调试器在此位置中断。这是一段故意破坏 "strict" 模式规则以生成错误的代码,以便可以从产生的错误中选择调用堆栈。如果您可以在调试器设置中忽略此错误类型,Chromium 调试器将不再烦扰您。它只会在 Dexie.debug === true 时发生(这是从 localhost 提供的站点的默认设置)。您在控制台日志中获得的功能是未处理拒绝的异步堆栈跟踪。您可以通过设置 Dexie.debug = false.

明确关闭它

源代码如下:

export function getErrorWithStack() {
"use strict";
if (NEEDS_THROW_FOR_STACK) try {
    // Doing something naughty in strict mode here to trigger a specific error
    // that can be explicitely ignored in debugger's exception settings.
    // If we'd just throw new Error() here, IE's debugger's exception settings
    // will just consider it as "exception thrown by javascript code" which is
    // something you wouldn't want it to ignore.
    getErrorWithStack.arguments;
    throw new Error(); // Fallback if above line don't throw.
} catch(e) {
    return e;
}
return new Error();
}