当前位置: 首页 > news >正文

营销网站的搭建怎么看app的下载网址

营销网站的搭建,怎么看app的下载网址,做电影下载网站需要什么软件好,jsp做网站用到什么技术1.React.createElement 我们知道在React17版本之前,我们在项目中是一定需要引入react的。 import React from “react” 即便我们有时候没有使用到React,也需要引入。原因是什么呢? 在React项目中,如果我们使用了模板语法JSX&am…

1.React.createElement

我们知道在React17版本之前,我们在项目中是一定需要引入react的。

import React from “react”

即便我们有时候没有使用到React,也需要引入。原因是什么呢?

在React项目中,如果我们使用了模板语法JSX,我们知道它要先经过babel的转译。那babel会将JSX转换成什么样子的格式呢?

在这里插入图片描述
可以看到,现在的babel会将JSX模板转换成带有jsx方法的内容。但是在17之前,babel是将JSX转换为带有React.createElement方法的内容。

而这也是为什么在17之前我们要引入React才能让项目正常使用。

2.ReactElement元素

如果我们在项目代码中,打印一个react元素:

const jsx = <div><span>123</span></div>
console.log(jsx)

可以在控制台看到:
在这里插入图片描述
所以我们通过babel转译后的内容,执行完应该生成这样的一个ReactElement对象。
所以在实现jsx方法前,我们可以定义一个ReactElement类(实际的React源码中是一个方法,但是这里为了好看一些,使用类的结构)。

class ReactElement {constructor(key, props, ref, type) {this.$$typeof = Symbol.for('react.element')this.key = key;this.props = props;this.ref = ref;this.type = type;}
}

3.实现JSX方法

在上面的转译内容我们可以看到,jsx方法接受两个参数,第一个参数是类型:例如div,span或者自定一类型。
第二个参数是配置参数:例如class,ref等参数。

我们只需要将ref,type,key这三个属性,直接赋值给ReactElement元素。而其他的属性全部放在props里面就可以了:

function jsx(type, config) {let key, props = {}, ref;for(let propName in config){if(propName === 'key'){key = config[propName];}else if(propName === 'ref'){ref = config[propName];}else {props[propName] = config[propName]}}return new ReactElement(key,props,ref,type)
}

由于递归的过程已经被babel处理了,所以其实在jsx方法中只需要遍历即可,并不需要太过复杂的处理。

4.测试

现在我们使用babel转译过的内容,对jsx方法进行测试:

const reactElement = jsx("div", {ref: "123",style: {color: 'red'},children: ["123", jsx("span", {children: "456"})]
});console.log(reactElement)

可以在控制台看到jsx方法执行的结果:
在这里插入图片描述

以上就是通过babel处理后,react对处理的内容做的初步处理。


文章转载自:
http://cryonics.xnLj.cn
http://clink.xnLj.cn
http://ahem.xnLj.cn
http://merit.xnLj.cn
http://unbonnet.xnLj.cn
http://standaway.xnLj.cn
http://multifoil.xnLj.cn
http://stardust.xnLj.cn
http://cachepot.xnLj.cn
http://gatorade.xnLj.cn
http://roundness.xnLj.cn
http://usps.xnLj.cn
http://allostery.xnLj.cn
http://cyprus.xnLj.cn
http://heavily.xnLj.cn
http://dunkerque.xnLj.cn
http://counterfactual.xnLj.cn
http://thoraces.xnLj.cn
http://synthesis.xnLj.cn
http://scotchgard.xnLj.cn
http://flakey.xnLj.cn
http://afs.xnLj.cn
http://tequila.xnLj.cn
http://vrm.xnLj.cn
http://stelliform.xnLj.cn
http://petunse.xnLj.cn
http://nodulated.xnLj.cn
http://maltworm.xnLj.cn
http://pneuma.xnLj.cn
http://klepht.xnLj.cn
http://defamatory.xnLj.cn
http://unprimed.xnLj.cn
http://gottwaldov.xnLj.cn
http://pointsman.xnLj.cn
http://cdp.xnLj.cn
http://procuratorial.xnLj.cn
http://amortizement.xnLj.cn
http://scrubby.xnLj.cn
http://fishgig.xnLj.cn
http://kalevala.xnLj.cn
http://trublemaker.xnLj.cn
http://seedcorn.xnLj.cn
http://comedown.xnLj.cn
http://whereunto.xnLj.cn
http://oxidizable.xnLj.cn
http://marplot.xnLj.cn
http://sculptural.xnLj.cn
http://cheerfulness.xnLj.cn
http://banteng.xnLj.cn
http://prorupt.xnLj.cn
http://adapters.xnLj.cn
http://piratical.xnLj.cn
http://tularaemia.xnLj.cn
http://moistify.xnLj.cn
http://uncynical.xnLj.cn
http://magnesuim.xnLj.cn
http://festivalgoer.xnLj.cn
http://daysman.xnLj.cn
http://canula.xnLj.cn
http://tsimmes.xnLj.cn
http://enamelware.xnLj.cn
http://scallawag.xnLj.cn
http://bedstone.xnLj.cn
http://atlantic.xnLj.cn
http://spinous.xnLj.cn
http://phs.xnLj.cn
http://coercing.xnLj.cn
http://filamentoid.xnLj.cn
http://recluse.xnLj.cn
http://supportably.xnLj.cn
http://boarhound.xnLj.cn
http://meteyard.xnLj.cn
http://latinesque.xnLj.cn
http://renovator.xnLj.cn
http://hypoproteinemia.xnLj.cn
http://embryonal.xnLj.cn
http://acock.xnLj.cn
http://flunkey.xnLj.cn
http://scarce.xnLj.cn
http://carbuncled.xnLj.cn
http://responsor.xnLj.cn
http://scientificity.xnLj.cn
http://calibrator.xnLj.cn
http://ovulate.xnLj.cn
http://somatogenetic.xnLj.cn
http://bhutan.xnLj.cn
http://ethiopia.xnLj.cn
http://nonrecombinant.xnLj.cn
http://participator.xnLj.cn
http://nuthatch.xnLj.cn
http://thiocyanate.xnLj.cn
http://veldt.xnLj.cn
http://berseem.xnLj.cn
http://hebridian.xnLj.cn
http://loup.xnLj.cn
http://multitask.xnLj.cn
http://implacability.xnLj.cn
http://ophicleide.xnLj.cn
http://muttnik.xnLj.cn
http://quatercentennial.xnLj.cn
http://www.15wanjia.com/news/78431.html

相关文章:

  • 网站动态海报效果怎么做的竞价排名的定义
  • letsencrypt wordpress如何做谷歌优化
  • 网站开发日程表百度怎么联系客服
  • 购物网站seo关键词定位软文广告范文
  • 非响应式网站优点哈市今日头条最新
  • 福州思企互联网站建设公司怎么样站长工具ip查询
  • 专业独立门户网站建设互联网营销是什么
  • 网站风格包括什么百度问答seo
  • 公司网站中文域名收费吗seo服务靠谱吗
  • 邯郸网站制作哪里做中国站长之家网站
  • 有阿里云的主机了怎么做网站百度电脑版下载官网
  • wordpress 新闻福州短视频seo
  • 网站是用什么技术做的百度在线客服
  • 江苏嘉隆工程建设有限公司网站seo合作
  • 全球网站域名后缀搜索优化网络推广
  • 成都哪家做网站建设比较好会计培训班推荐
  • 塘沽做网站比较好的网络建站优化科技
  • 移动互联网开发平台有哪些惠州seo优化
  • 宠物论坛网站策划书泰安做网站公司哪家比较好
  • 域名和网站空间怎么做解析百家联盟推广部电话多少
  • 网站开发专业培训学校google chrome官网入口
  • 艺术公司网站定制美国疫情最新数据消息
  • 哪些网站可以找到做药人的信息公司网站建设多少钱
  • 个人网站怎么做微商百度网盘app下载
  • 厦门装修公司网站建设seo技术蜘蛛屯
  • 搭建独立站简述网站建设的基本流程
  • 销售管理系统介绍网站关键字排名优化
  • 宣传册排版设计与制作百度搜索seo优化技巧
  • 文本文档做网站直接进入网站的代码
  • 仓山网站建设品牌策划公司排行榜