(精华)2020年8月10日 React-Native hook的使用
发布日期:2021-06-29 15:09:11 浏览次数:2 分类:技术文章

本文共 844 字,大约阅读时间需要 2 分钟。

useState 使用也和react一样,其他也一样就不多举例

import React, {
Component, useState } from 'react';import {
View, Text, StyleSheet, Button} from 'react-native';export default function Flex () {
const [count, setCount] = useState(0) const addCount = () => {
let newCount = count setCount(newCount += 1) } handelClick = () => {
alert('dianji') } return (
{
count}
Image source={
require('./img/dask.gif')} style={
{
width: 300, height: 300 }}>
Hello World!
)}const styles = StyleSheet.create({
container: {
width: 100, height: 100, margin: 10, backgroundColor: 'gray' }, text: {
fontSize: 20, margin: 20 }})

转载地址:https://codeboy.blog.csdn.net/article/details/107923080 如侵犯您的版权,请留言回复原文章的地址,我们会给您删除此文章,给您带来不便请您谅解!

上一篇:2021-05-25 .NET高级班 05-手写ORM
下一篇:(精华)2020年8月10日 React-Native 组件的生命周期

发表评论

最新留言

路过,博主的博客真漂亮。。
[***.116.15.85]2024年04月02日 23时25分29秒