为g元素添加属性无效
import React from 'react';
import * as d3 from 'd3'
import './Dthree.css'
class Dthree extends React.Component{
constructor(props){
super(props)
this.useD3 = this.useD3.bind(this)
}
componentDidMount(){
this.useD3()
}
useD3() {
const svg1 = d3.select('#container')
.append('svg')
.attr("width", 500)
.attr("height", 250)
const g = d3.select('svg')
.append('g')
.attr('transform', 'translate(50,50)')
.style('width','50px')
}
render () {
return (
<div id='container'>
</div>
)
}
}
export default Dthree