leaflet popup string html使用react.js无法正确显示

时间:2018-04-03 17:39:46

标签: javascript html string reactjs leaflet

我有以下代码试图在弹出窗口中显示html:

layer.bindPopup(
  `<p data data-campaign="4" data-token="${this.state.reg_mapping[feature.properties.name]}">
  <h4>Region: ${feature.properties.name}</h4>
  <h4 data-token-re></h4>
  <button type="submit" data-button>Donate Now</button>
</p >`
);

问题在于我希望p标签是所有元素的父标记,但是当我在检查器中时,我可以看到p标记关闭,因此不是其他元素的父标记。怎么解决这个问题?

编辑:我正在使用react.js

enter image description here

1 个答案:

答案 0 :(得分:2)

<p>替换为<div>。段落不能包含标题<h4>标记。