react-native如何在picker中设置fontSize

时间:2018-06-16 08:59:18

标签: reactjs react-native

import React, { Component } from 'react';
import { Picker } from 'react-native';

export default class pik extends Component {
  render() {
    return (
      <Picker
        selectedValue={'Hotels'}
        mode={'dropdown'}
        style={{
          height: 50,
          width: 150,
          fontSize: 50,
        }}>
        <Picker.Item style={{ fontSize: 100 }} label="Hotels" value="Hotels" />
        <Picker.Item label="Food" value="Foosd" />
      </Picker>
    );
  }
}

错误

enter image description here enter image description here

LIVE DEMO ERROR

1 个答案:

答案 0 :(得分:-1)

如果要设置样式以应用于每个项目标签,请使用itemStyle

import React, { Component } from 'react';
import { Picker } from 'react-native';

export default class pik extends Component {
  render() {
    return (
      <Picker
        selectedValue={'Hotels'}
        mode={'dropdown'}
        itemStyle={{
          height: 50,
          width: 150,
          fontSize: 50,
        }}>
        <Picker.Item style={{ fontSize: 100 }} label="Hotels" value="Hotels" />
        <Picker.Item label="Food" value="Foosd" />
      </Picker>
    );
  }
}