ITPub博客

首页 > IT职业 > IT图书 > react.js学习笔记,基础

react.js学习笔记,基础

IT图书 作者:petterchx 时间:2021-09-09 08:57:58 0 删除 编辑

组件首字母大小写 react 中的组件大写,dom组件小写
组件可以嵌套
大括号里不可以用语句,得用求值表达式,可以用+ - * ..函数也可以使用
驼峰命名
htmlFor 和 className 是jsx中用的,用来代替class和html(保留字无法使用)
在内容里添加注释用{}
在节点里直接添加注释

class App extends Component {
    getName() {
        if(this.props.name){
            return this.props.name
        }else {
            return "hehehda";
        }
    }

  render() {
    return (
      
logo

Welcome to React {this.getName()} 123s45{ /** * dswew */ }

To get ssstarted, edit 22src/App.js and save to reload. 12

); } } export default App;

来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/4606/viewspace-2798308/ ,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论

注册时间:2019-10-24

  • 博文量
    131
  • 访问量
    30132