网页
<html>
<head>
<title>D3 external svgs</title>
<script src="http://d3js.org/d3.v3.min.js"></script>
</head>
<body>
<object data="circles.svg" type="image/svg+xml" id="circles"></object>
<script>
function changeColor() {
var sel = d3.select(document.getElementById("circles").contentDocument).selectAll("circle");
if(sel.empty()) {
setTimeout(changeColor, 100);
} else {
sel.attr("fill", "black");
}
}
changeColor();
</script>
</body>
</html>
svg
<svg xmlns="http://www.w3.org/2000/svg" width="100px" height="100px" >
<circle id="c_red" fill="#A00" stroke="#000" cx="40" cy="40" r="40"/>
<circle id="c_grn" fill="#0A0" stroke="#000" cx="60" cy="60" r="40"/>
</svg>
注意事项:一定要搭建服务器
本文分享自 传输过程数值模拟学习笔记 微信公众号,前往查看
如有侵权,请联系 cloudcommunity@tencent.com 删除。
本文参与 腾讯云自媒体同步曝光计划 ,欢迎热爱写作的你一起参与!