2016-08-05 5 views
1

정적 기본 스타일 시트 스타일로 동적 인라인 스타일을 지정해야합니다. 어떻게해야합니까?기본 스타일 시트가있는 동적 인 스타일 기본 기본 스타일

<View 
    style={[styles.card,{{width:width, height: height}}]}> 
      <View style={styles.card}> 
       <Text> 
        <Image 
        source={{uri: this.props.media.image_url}} 
        style={{width:width, height: this.props.media.height}}/> 
       </Text> 
      </View> 
</View> 

위 코드는 저에게 적합하지 않습니다.

+0

서버 렌더링을 사용하려면 서버 렌더링에서 스타일 로더가 지원되지 않으므로 나중에 변경해야 할 수도 있습니다. – abhirathore2006

+0

서버 렌더링을위한 솔루션은 무엇이 될 수 있습니까? –

+0

https://github.com/webpack/extract-text-webpack-plugin을 사용하면 모든 파일을 하나의 파일에 결합합니다. – abhirathore2006

답변

2

아니하다.

style={[styles.card,{{width:width, height: height}}]} 

에 : 당신은 실제로 위의 답변에서 같은 일을 한

style={[styles.card,{width:width, height: height}]} 

당신은 추가 괄호

변경이 그들을 감쌌다.

0

마지막으로 많은 시도를 한 후 해결할 수 있습니다. 여기에 제대로 동적 (인라인 스타일)을 통과하지 않은 문제가 순서 아니라, 코드

<View 
    <View style={[{width:width, height: height},styles.card]}> 
     <View style={styles.card}> 
      <Text> 
       <Image 
       source={{uri: this.props.media.image_url}} 
       style={{width:width, height: this.props.media.height}}/> 
      </Text> 
     </View> 
    </View> 
</View> 
+0

솔루션을 명확히하기 : 스타일의 순서는 중요합니다. 왼쪽에서 오른쪽으로 적용되므로, styles.card가 너비와 높이보다 우선합니다. – Hanse