前端知识总结
时间:2023-04-04 22:56:42
HTML5
react-helmet作用:可以管理页面的headExampleimportReactfrom"react";import{Helmet}from"react-helmet";classApplicationextendsReact.Component{render(){return(我的标题头盔>...
);}};嵌套或后面的组件将覆盖重复的更改:
我的标题嵌套标题outputs:<title>NestedTitle
dvadva首先是一个基于redux和redux-saga的数据流解决方案,然后为了简化开发经验,dva也内置了react-router和fetch,所以也可以理解为一个轻量级的应用框架官网链接:https://dvajs.com/Generator形式上Generator功能就是一个普通的功能,但它有两个特点。一种是函数关键字和函数名之间有一个星号;另一种是在函数体内使用yield表达式来定义不同的内部状态(yield在英文中是“输出”的意思)。函数*helloWorldGenerator(){yield'hello';产生“世界”;return'ending';}varhw=helloWorldGenerator();hw.next()//{value:'hello',done:false}hw.next()//{value:'world',done:false}hw.next()//{value:'ending',done:true}hw.next()//{value:undefined,done:true}PromiseCallbackfs.readFile(fileA,'utf-8',function(err,data){fs.readFile(fileB,'utf-8',function(err,data){//...});});PromisevarreadFile=require('fs-readfile-promise');readFile(fileA).then(function(data){console.log(data.toString());}).then(function(){returnreadFile(fileB);}).then(function(data){console.log(data.toString());}).catch(function(err){console.log(err);});coroutinefunction*asyncJob(){//...其他代码varf=yieldreadFile(fileA);//...其他代码}Coroutines传统的编程语言很早就有异步编程的解决方案(其实就是多任务的解决方案)。其中之一称为“协程”,意思是多个线程相互协作完成异步任务。协程有点像函数,也有点像线程。其运行过程大致如下。第一步,协程A开始执行。第二步,协程A执行到一半,进入暂停,执行权转移给协程B。第三步,(一段时间后)协程B归还执行权。第四步,协程A恢复执行。上述流程的协程A是一个异步任务,因为它被分成了两次(或多次)执行。vargen=function*(){varf1=yieldreadFile('/etc/fstab');varf2=yieldreadFile('/etc/shells');console.log(f1.toString());console.log(f2.toString());};varco=require('co');co(gen);co(gen).then(function(){console.log('生成器函数执行完成');});RESTfulREST的全称是RepresentationalStateTransfer,中文意思是具象状态传输统一资源接口GET、DELETE、PUT和POST。