measure()測量是根據view標簽中的ref屬性,使用方法如下:
measureWatermarkerImage(){
this.refs.watermarkerImage.measure((a, b, width, height, px, py) =>
this.setState({watermarkerImageWidth: width})
);
}
with:寬;height:高;px:x軸方向距離左邊多少像素;py:y軸方向距離上邊多少像素;
根據項目需要,如果需要在頁面加載完成后進行測量view,就需要使用setTimeout():
componentDidMount() {
setTimeout(this.measureWatermarkerImage.bind(this));
};
