摘要: 1. useState 作用: 给函数组件添加状态 import React, {useState} from 'react'; const [name, setName] = useState('张三'); // 使用useState来创建状态 1. 引入useState ,import Reac 阅读全文
posted @ 2024-03-19 00:15 王二狗的春天 阅读(2) 评论(0) 推荐(0) 编辑
摘要: 数组解构: const foo = [1,2,3] const [a, b, c] = foo; console.log(a,b,c) // 1,2,3 对象解构: const obj = { name: 'AA', id: '111'}const {name, id} = obj; console 阅读全文
posted @ 2024-03-18 23:43 王二狗的春天 阅读(4) 评论(0) 推荐(0) 编辑
摘要: 事件名称不同: 原生:全小写 React:小驼峰 onClick 事件函数处理 原生:字符串 React:函数 onClick={} 阻止浏览器本身的默认行为 原生:return false React:preventDefault() 阅读全文
posted @ 2024-03-18 22:52 王二狗的春天 阅读(3) 评论(0) 推荐(0) 编辑
摘要: 1、其他值 -> 数字 : ① Number() Number('123') // 123 Number('123.4') // 123.4 Number('123年') // NaN Number('2e3') // 2000 Number('') // 0 注:纯数字字符串能变为数字,不是纯数字 阅读全文
posted @ 2023-02-21 16:16 王二狗的春天 阅读(37) 评论(0) 推荐(0) 编辑
摘要: 阅读全文
posted @ 2023-02-21 14:37 王二狗的春天 阅读(12) 评论(0) 推荐(0) 编辑
摘要: null 数组 对象 检测结果均为Object 阅读全文
posted @ 2023-02-21 14:35 王二狗的春天 阅读(8) 评论(0) 推荐(0) 编辑
摘要: 1、charAt(index) 得到指定位置字符,index为字符串索引值。 eg:let str = '我是一个字符串' str.charAt(4) //'字' str.charAt(80) //'' 2、substring(a,b) 得到从a开始到b结束(不包含b)的子串,a、b均为索引值,a不 阅读全文
posted @ 2023-02-21 14:24 王二狗的春天 阅读(67) 评论(0) 推荐(0) 编辑
摘要: 子选择器:.box>p{ color: red}<div class='box'> <p>我是段落</p> <p>我是段落</p> <div> <p>我是段落</p> </div> </div>而 .box p{ color: red } <div class='box'> <p>我是段落</p> 阅读全文
posted @ 2022-09-05 15:47 王二狗的春天 阅读(31) 评论(0) 推荐(0) 编辑
摘要: caption属性为表格的标题 要放在表格中的第一个tr之前。 <table> <caption>我是表格的标题</caption> <tr> <th>第一季度</th> <th>第二季度</th> <th>第三季度</th> <th>第四季度</th> </tr> <tr> <td>A</td> 阅读全文
posted @ 2022-08-17 11:52 王二狗的春天 阅读(126) 评论(0) 推荐(0) 编辑
摘要: <datalist> 控件可以为输入框提供一些备选选项,当用户输入的内容与备选选项文字相同时,将会显示智能感应 注: 此时的option为单标签 <input type='text' list='province-list'> <datalist id='province-list'> <optio 阅读全文
posted @ 2022-08-17 11:36 王二狗的春天 阅读(396) 评论(0) 推荐(0) 编辑