React学习总结一、邂逅React开发1. React开发的三个依赖包是什么?分别有什么作用?
react:包含react所有必须的核心代码
react-dom:react 渲染在不同平台所需要的核心代码
babel:将jsx转换为 React 代码的工具
2. React如何封装组件,组件里面包含哪些内容?
类的方式封装组件
定义一个类(类名大写,组件的名称是必须大写的,小写会被认为是HTML元素),继承自React.Component
.实现当前组件的render函数
123456789class App extends React.Component{ render(){ return <h2> Hello React<h2/> }}#渲染根组件const root =ReactDOM.createRoot(document.querySelector("#r oot"))#使用组件root.render(<App/>)
3. 在进行函数绑定时...
JavaScript函数中this的指向[toc]
一、函数的基本用法12345678910111213// 定义函数 function foo(name) { console.log("foo函数:", this) } // 1.方式一: 直接调用 // foo() // 2.方式二: 通过对象调起 var obj = { name: "why" } obj.aaa = foo obj.aaa()
二、this绑定规则1. this绑定规则一:默认绑定默认绑定规则描述 :
默认绑定是最基本的规则,当函数调用不符合其他绑定规则(如隐式绑定、显式绑定或者new绑定)时应用。在默认绑定下,函数的调用方式决定了this的值:
非严格模式下,this默认绑定到全局对象(浏览器环境中是window对象)。
严格模式下,this将绑定到undefined,防止不小心修改全局对象。
(1)普通的函数被独立调用
12345678// &q...
Welcome to Hexo! This is your very first post. Check documentation for more info. If you get any problems when using Hexo, you can find the answer in troubleshooting or you can ask me on GitHub.
Quick StartCreate a new post1$ hexo new "My New Post"
More info: Writing
Run server1$ hexo server
More info: Server
Generate static files1$ hexo generate
More info: Generating
Deploy to remote sites1$ hexo deploy
More info: Deployment