我可以在 NextJS 中使用 Web 加密 api 吗?
我尝试使用
crypto.subtle.digest('SHA-256', data)
Run Code Online (Sandbox Code Playgroud)
但出现错误
ReferenceError: crypto is not defined
Run Code Online (Sandbox Code Playgroud) 我正在关注 Leaflet 的 Choropleth 教程
http://leafletjs.com/examples/choropleth.html
并使用 react-leaflet。我设法在没有对原始源代码进行任何修改的情况下设置了样式并且它可以工作。
highlightFeature(e) {
var layer = e.target;
layer.setStyle({
weight: 5,
color: '#666',
dashArray: '',
fillOpacity: 0.7
});
}
Run Code Online (Sandbox Code Playgroud)
该图层具有 setStyle 属性。现在要重置我有问题的样式。
我试图访问它
resetHighlight(e) {
this.refs.geojson.resetStyle(e.target);
}
同时拥有 GeoJson
<GeoJson
ref="geojson"
data={this.state.data}
style={this.getStyle.bind(this)}
onEachFeature={this.onEachFeature.bind(this)}
/>
Run Code Online (Sandbox Code Playgroud)
但它没有 resetStyle 属性
任何人都可以建议另一种在 react-leaflet 中重置样式的方法?
为什么即使使用IF检查,Flow仍然会抱怨可能为null的值
if(document && document.getElementById("myID") && document.getElementById("myID").offsetWidth){
console.log(document.getElementById("myID").offsetWidth);
}
Run Code Online (Sandbox Code Playgroud)
给出了这个错误
^ property `offsetWidth`. Property cannot be accessed on possibly null value
Run Code Online (Sandbox Code Playgroud) 为了防止在最高缩放级别上出现多个重复的世界地图,我正在使用noWrap=true选项。它运作良好,但仅在地图的左侧(灰色区域),右侧仍显示额外的图块。这是为什么?
UPDATE1:看起来是特定Mapbox磁贴或其加载方式存在问题吗?在这里noWrap和https://{s}.tiles.mapbox.com/v3/ebrelsford.ho06j5h0/{z}/{x}/{y}.png
完美运行:NoWrap可以运行JSBIN链接
但是一旦我改变了使用样式加载图块的另一种方式
我可以向右滚动但仍能获得图块
我打开了一个github问题,我怀疑这是库https://github.com/Leaflet/Leaflet/issues/5938的错误