当前位置: 首页 > news >正文

旅游响应式网站建设全网热搜榜

旅游响应式网站建设,全网热搜榜,酒类网站建设方案,一定得做网站认证写多了taro, 看见react native中的组件好亲切啊,几乎一模一样。 一、函数式组件 — 常用 1)无状态,每次刷新都是生成一个新的状态 2)基于状态变化的管理 3)简洁,代码少,易于服用 import Reac…

写多了taro, 看见react native中的组件好亲切啊,几乎一模一样。

一、函数式组件 — 常用

1)无状态,每次刷新都是生成一个新的状态
2)基于状态变化的管理
3)简洁,代码少,易于服用

import React from "react";
import { View, Text } from 'react-native';// 子组件 TestFunctionDemo.js
export default function TestFunctionDemo(props) {const { name, info: {age, sex} } = propsconst [address, setAddress] = useState('中国')useEffect(() => {// 第一次加载完成setTimeout(() => {setAddress('大陆')}, 2000)}, [])useEffect(() => {// 监听address}, [address])return (<View style={{height: 200, width: '80%', padding: 20, borderRadius: 10, backgroundColor: '#ccc'}}><Text>我是子组件</Text><Text>姓名:{ name }</Text><Text>年龄:{ age }</Text><Text>性别:{ sex }</Text><Text>{`地址:${ address }`}</Text>{ props.children}</View>)
}// 简写
const TestFunctionDemo = (props) => {// ...
}
export default TestFunctionDemo// 或
export default (props) => {// ...
}
二、class组件

1) 有状态state, 每次都是修改的同一个状态
2) 基于生命周期的管理

// 子组件 TestClassDemo .js
class TestClassDemo extends React.Component {constructor(props) {super(props)this.state = {address: '中国'}}componentDidMount() {setTimeout(() => {this.setState({address: '大陆'})}, 2000)}render() {const { name, info: {age, sex} } = this.propsconst { address } = this.statereturn (<View style={{height: 200, width: '80%', padding: 20, borderRadius: 10, backgroundColor: '#ccc'}}><Text>我是子组件</Text><Text>姓名:{ name }</Text><Text>年龄:{ age }</Text><Text>性别:{ sex }</Text><Text>{`地址:${ address }`}</Text>{ this.props.children}</View>)}
}export default TestClassDemo
三、父组件引入
// 父组件app.js中引入
import TestFunctionDemo from './src/components/TestFunctionDemo';
import TestClassDemofrom './src/components/TestClassDemo';// ...
const info = {age: 20,sex: 'nan'
}// ...<TestFunctionDemo name="zhangsan" info={info}><Text>我是通过插槽加入的!</Text>
</TestFunctionDemo><TestClassDemo name="zhangsan" info={info}><Text>我是通过插槽加入的!</Text>
</TestClassDemo>

在这里插入图片描述
以上是不是和react一模一样

四、样式

!!!这里和react不一样

import React from "react";
import { View, Text, StyleSheet } from 'react-native';// 子组件 TestFunctionDemo.js
export default (props) => {// ...return (<View style={styles.box}>// 多个样式用数组<Text style={[styles.textLine, styles.title]}>我是子组件</Text><Text  style={styles.textLine}>姓名:{ name }</Text>// ...</View>)
}// 样式
const styles = StyleSheet.create({box: {height: 200, width: '80%', padding: 20, borderRadius: 10, backgroundColor: '#ccc'},textLine: {fontSize: 18,color: 'blue'},title: {fontWeight: "bold"}
})

在这里插入图片描述

http://www.hkea.cn/news/329/

相关文章:

  • 设计本网站是用什么做的搜索引擎优化案例分析
  • 上海手机网站建设哪家好产品软文案例
  • 网站为什么吸引人b站推广怎么买
  • ecs怎么做多个网站西安seo和网络推广
  • 网站的排名与权重网络安全有名的培训学校
  • 网站建设开发报价西安竞价托管代运营
  • 政府网站建设哪家好上海seo优化公司kinglink
  • 龙岗网站建设公司效果站长之家统计
  • 男女做爰网站19哪个公司的网站制作
  • 桂林生活网招聘淄博seo培训
  • 兴科cms网站建设系统seopeix
  • 上海法律网站建设常见的网络营销工具有哪些
  • 干部重庆网络学院百度seo关键词报价
  • 网站自己怎么做优化seo常用工具包括
  • 网站响应速度验收seo网站优化方案
  • 呼伦贝尔哪里做网站免费b2b网站大全免费
  • 如何建造一个网站免费外链网盘
  • 专业网站优化报价百度官方优化指南
  • 义乌网站备案哪家网络推广好
  • 定制网站制作费用阿里指数查询手机版
  • 深圳快速网站制作服务优化算法
  • 网站怎么放到服务器上全媒体运营师
  • 女生做网站运营上海外贸网站seo
  • ecshop模板济南seo整站优化招商电话
  • 网站 规划方案一个平台怎么推广
  • 黑龙江省新闻seo网站优化培
  • php做网站图集软文代发代理
  • 网站建设jnlongji网站seo优化价格
  • 服装网站搭建计划书google seo是什么
  • 自己做的网站邮箱更改密码程序为什么总出错网站关键词怎么写