svn*_*vnm 7 javascript react-native styled-components
是否可以使用 StyleSheet 或样式组件在本机反应中进行转换?我正在尝试以下操作,但没有运气。
import React from 'react'
import styled from 'styled-components/native'
import { Text, View, StyleSheet } from 'react-native'
export default class extends React.Component {
render() {
return (
<Wrapper visible={visible}><Text>hello</Text>
)
}
}
const Wrapper = styled.View`
opacity: ${props => props.visible ? 1 : 0};
transition: opacity 1s linear;
`
const styles = StyleSheet.create({
wrapper: {
opacity: 1,
transition:'opacity 1s linear'
}
});
Run Code Online (Sandbox Code Playgroud)
React Native 不支持这种方式的 React 样式转换,而是尝试 RN Animated View 库,它的工作原理非常相似(并且使用内联样式/组件):
https://facebook.github.io/react-native/docs/animated.html
| 归档时间: |
|
| 查看次数: |
9643 次 |
| 最近记录: |