1 Star 0 Fork 0

nick91/RNTestDemo

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
TestComponent.js 1.20 KB
一键复制 编辑 原始数据 按行查看 历史
nick91 提交于 2018-06-29 17:10 . 首次提交
import {Component} from 'react'
import React from "react";
import {Text, View} from "react-native";
import LifeComponent from "./LifeCycleComponent"
//导入变量和导入方法一样
import {age, name, sex, sum} from "./NickComponent";
export default class TestComponent extends Component{
constructor(props){
super(props);
this.state = ({
remove: false,
num: 0,
result:0
});
}
render(){
let view = this.state.remove ? null : <LifeComponent/>;
let text = this.state.remove ? "让他复活" : "干掉他";
return (<View>
<Text style={{fontSize: 20}}
onPress={() => {
this.setState({
remove: !this.state.remove
})
}}>{text}</Text>
{view}
<Text style={{fontSize:20,backgroundColor:'green'}}
onPress={()=>{
let result = sum(2,3);
this.setState({
result:result
})
}}>{name}{age}{sex}{this.state.result}</Text>
<LifeComponent/>
</View>)
}
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/nick91/RNTestDemo.git
[email protected]:nick91/RNTestDemo.git
nick91
RNTestDemo
RNTestDemo
master

搜索帮助