Nad*_*bit 14
您可以调用该onLayout事件来测量元素:
measureView(event) {
console.log('event properties: ', event);
console.log('width: ', event.nativeEvent.layout.width)
}
<View onLayout={(event) => this.measureView(event)}>
Run Code Online (Sandbox Code Playgroud)
就宽度和高度百分比而言,您可以获得窗口宽度和高度,并使用它们:
var {
...
Dimensions
} = React
const width = Dimensions.get('window').width
const height = Dimensions.get('window').height
// 80% width
width: width * .8,
// 25% height
height: height / 4,
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
13179 次 |
| 最近记录: |