美文网首页
react第三天

react第三天

作者: 怎么昵称 | 来源:发表于2022-11-17 10:09 被阅读0次

import component

function Profile(){
    return (
    <img
      src="ddd.jpg"
      alt = "dehuejson"
    ></img>
    )
}

export default function Gallery(){
    return (
        <section>
            <h1>dedhue</h1>
            <Profile />
            <Profile />
            <Profile />
        </section>
    )
}
import Gallery from './Gallery.js'

export default function App(){
    return (
        <Gallery />
    )
}

某个函数组件可以导出 在其他组件中使用


export function Profile() {}


import  {Profile} from './Gallery.js'

export default function App(){
    return <profile />
}

the rules of JSX
有一个唯一的根节点

export default function  todoList(){
   return (
     <div> 
      //或 <>        
       <h1>Hedy Lamarr's Todos</h1>
       <img 
         src="https://i.imgur.com/yXOvdOSs.jpg" 
         alt="Hedy Lamarr" 
         class="photo"
       >
       <ul>
         <li>Invent new traffic lights
         <li>Rehearse a movie scene
         <li>Improve the spectrum technology
       </ul>

   </div>
   //或</>

   )
}

所有的tag标签都要有结尾标签
<img />
<li><li/>

<>
  <img 
    src="https://i.imgur.com/yXOvdOSs.jpg" 
    alt="Hedy Lamarr" 
    class="photo"
   />
  <ul>
    <li>Invent new traffic lights</li>
    <li>Rehearse a movie scene</li>
    <li>Improve the spectrum technology</li>
  </ul>
</>

className =“字符串”
src = {url}
alt = {desc}
用变量的形式存储 加{}

export default function Avatar(){
    const avatar = 'https://i.img.jpg'
    const desc  ='Aaaa'
    return (
        <img 
         className = "avatar"
         src = {avatar}
         alt = {desc}
        />
    )
}

所有的已存在的变量 和 函数
都可以再return中 用 {} 渲染出来

const today = new Date();

function formatDate(date) {
  return new Intl.DateTimeFormat(
    'en-US',
    { weekday: 'long' }
  ).format(date);
}


export default function TodoList() {
  const name = 'Gregorio Y. Zara';

  return (
    <h1>{name}'s To Do List</h1>
    <h1>To Do List for {formatDate(today)}</h1>
  );
}

相关文章

  • react第三天

    react的核心知识点虚拟domJSX语法单向数据绑定组件化 虚拟dom的概念 1.虚拟dom和dom的本质区别:...

  • React第三天

    默认属性 组件名.defaultProps = {} 例如:在class组件外部添加 数据类型检查 1.安装: 2...

  • react第三天

    import component 某个函数组件可以导出 在其他组件中使用 the rules of JSX有一个唯...

  • React第三天学习

    一、生命周期 1.页面渲染期 constructor ...

  • 2018-08-01

    第三天 主要回顾了一下 React 文档,有了新的体会 每次更新发生时都会调用 render 方法,但只要我们将 ...

  • React Native 学习第三天

    <1>.WebStorm汉化 下载地址 从新启动WebStorm即可! <2>.TextInput控件 详细网址:...

  • react学习第三天笔记

    react路由 模块 下载react-router模块,版本3.0.5; 解构赋值:Router,Route,ha...

  • React基础

    react 教程 react 组件介绍 react state 介绍 react Props 介绍 React:组...

  • 学习react no.1

    学习react no.1 react 定义 react 特点 react

  • React Native 学习之路

    React 相关资料 React Components React Properties React State ...

网友评论

      本文标题:react第三天

      本文链接:https://www.haomeiwen.com/subject/dufexdtx.html