d3入门
d3的安装 npm install d3 --save 在需要的文件中导入 import * as d3 from "d3" 向svg中填充图形 <template> <div class="dthreeAppend"> <p class="title">This is a d3</p> <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xml:space="preserve" width="600" height="300"></svg> </div> </template> <script> import * as d3 from "d3" export default { mounted(){ var svg=d3.select('svg') .attr('width',600) .attr('height',400) svg.append('circle') .attr('cx',100) //cx,cy圆心坐标 .attr('cy',200) .attr('r',50) //r圆心半径 .attr('fill','blue'); //将圆设置为蓝色 svg.append('rect') //矩形 .attr('x',50) //矩形左上角横坐标 .attr(