如何通过state实现长尾词的闪烁效果?
- 内容介绍
- 文章标签
- 相关推荐
本文共计128个文字,预计阅读时间需要1分钟。
ReactNative BlinkApp 简介 // http://reactnative.cn/docs/next/state.使用 React 和 Component 从 'react' 导入;使用 AppRegistry、Text 和 View 从 'react-native' 导入;class Blink 继承自 Component;构造函数中调用 super(props);
// reactnative.cn/docs/next/state.html
import React, { Component } from 'react';
import { AppRegistry, Text, View } from 'react-native';
class Blink extends Component {
constructor(props) {
super(props);
this.state = { showText: true };
// 每1000毫秒对showText状态做一次取反操作
setInterval(() => {
this.setState(previousState => {
return { showText: !previousState.showText };
});
}, 1000);
}
render() {
// 根据当前showText的值决定是否显示text内容
let display = this.state.showText ? this.props.text : ' ';
return (
本文共计128个文字,预计阅读时间需要1分钟。
ReactNative BlinkApp 简介 // http://reactnative.cn/docs/next/state.使用 React 和 Component 从 'react' 导入;使用 AppRegistry、Text 和 View 从 'react-native' 导入;class Blink 继承自 Component;构造函数中调用 super(props);
// reactnative.cn/docs/next/state.html
import React, { Component } from 'react';
import { AppRegistry, Text, View } from 'react-native';
class Blink extends Component {
constructor(props) {
super(props);
this.state = { showText: true };
// 每1000毫秒对showText状态做一次取反操作
setInterval(() => {
this.setState(previousState => {
return { showText: !previousState.showText };
});
}, 1000);
}
render() {
// 根据当前showText的值决定是否显示text内容
let display = this.state.showText ? this.props.text : ' ';
return (

