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

模版网站可以做seo吗谷歌seo服务商

模版网站可以做seo吗,谷歌seo服务商,wordpress清除redis缓存,qq空间网页版在线登录入口1 react的高阶组件 1.1 操纵组件的props、对组件的props进行增删; 1.2 复用组件逻辑 服用的组件逻辑,互不影响;比如高阶组件中复用了input框,输入内容是互不影响的; 1.3 可以通过配置装饰器来实现高阶组件&#xff08…

1 react的高阶组件

1.1 操纵组件的props、对组件的props进行增删;
1.2 复用组件逻辑
服用的组件逻辑,互不影响;比如高阶组件中复用了input框,输入内容是互不影响的;
1.3 可以通过配置装饰器来实现高阶组件(只能在类组件中使用)
之前:

import { test } from './test.jsx';
export default test(A);

现在:

import { test } from './test.jsx';
@test
export default A;

1.4 利用forwardRef,通过ref转发获取DOM节点
高阶组件test

export default class App extends React.Component {constructor() {super();this.testRef = React.createRef();}render() {return (<div><p>App Page</p><A ref={this.testRef} /><B /></div>);};componentDidMount() {console.log(this.testRef.current);}
}

第一种情况:

export default function test(Comp) {class HOC extends React.Component {render() {return <Comp {...this.props} />;};}return HOC;
}

如果A组件不使用高阶组件,this.testRef.current指的是A组件实例;
A组件使用了高阶组件,this.testRef.current指的是高阶组件实例;

第二种情况:
命名forwardRef,将ref传下去

export default function test(Comp) {class HOC extends React.Component {render() {return <Comp {..this.props}/>;};}return React.forwardRef((props, ref) => {return <HOC {...props} forwardRef={ref} />})
}
@test
class A extends React.Component {render() {return (<div ref={this.props.forwardRef}><p>A Component</p></div>);};
}

this.testRef.current指的是A组件实例,可以拿到DOM节点

1.5 反向继承(可以做渲染劫持)
之前高阶组件传入一个组件,返回一个组件,返回的组件 extends React.Component,这种叫属性代理
下面这种叫反向继承,可以做渲染劫持

export default function test(Comp) {return class extends Comp {render() {const element = super.render(); // super.render()返回虚拟DOMconst newProps = element.type === 'div'? { style: { color: '#f00' } }: { style: { color: '#0f0' } };return React.cloneElement(element,{ ...this.props, ...newProps },element.props.children,);};}
}

2 受控组件和非受控组件

是否受控取决于 是否可以使用state控制输入框

<input />这样的输入框是非受控的,即使使用<input defaultValue="Initial text" />传递了初始值,JSX也只是指定了初始值,而非当前时刻的值,也属于非受控组件;

如果要渲染一个受控输入框,请传递 value 属性(或者向多选框和单选框按钮传递 checked);React将强制传递 value属性给输入框,通常可以通过声明一个 state 来控制输入框;

function Form() {const [firstName, setFirstName] = useState('');return (<inputvalue={firstName}onChange={e => setFirstName(e.target.value)}/>)
}

看下面的例子

<form>受控:<input type="text" value={num} />非受控:<input type="text" defaultValue={num} /><button type="button" onClick={() => setNum(num + 1)}>+1</button>
</form>

点击按钮,受控组件值会变,但是非受控组件值不变,不受状态影响;
受控组件值不可以手动输入更改;非受控组件可以;
原因是受控组件没有加onChange,应该要配套使用;

那么如何获取受控组件和非受控组件的值?
获取受控组件的值:直接打印num即可;
获取非受控组件的值:通过获取元素document,再去获取元素的值;
或者使用ref

const dv = useRef(null);
<form>非受控:<input type="text" ref={dv} defaultValue={num} />
</form>

dv.current.value可以获取非受控组件的值;

总结:

  1. defaultValue非受控,不随num值变化而变化;value受控,随num值变化而变化;
  2. defaultValue可以直接编辑;value不能直接编辑(需要配合onChange事件);
  3. 获取值:受控组件直接读取num值;非受控组件通过ref获取值

3 Redux

单一状态树 store


文章转载自:
http://dinncogelatinous.tqpr.cn
http://dinncobanger.tqpr.cn
http://dinncostethoscope.tqpr.cn
http://dinncosequestra.tqpr.cn
http://dinncocensorate.tqpr.cn
http://dinncobejewlled.tqpr.cn
http://dinncospheroidal.tqpr.cn
http://dinncostile.tqpr.cn
http://dinncosarrusophone.tqpr.cn
http://dinncogypseous.tqpr.cn
http://dinncounsympathetic.tqpr.cn
http://dinncorevolution.tqpr.cn
http://dinncoevase.tqpr.cn
http://dinncoelusion.tqpr.cn
http://dinncolamaster.tqpr.cn
http://dinncoperspiratory.tqpr.cn
http://dinncogentler.tqpr.cn
http://dinncozambia.tqpr.cn
http://dinncofax.tqpr.cn
http://dinncoisomorphous.tqpr.cn
http://dinncowishbone.tqpr.cn
http://dinncotheir.tqpr.cn
http://dinncoovercover.tqpr.cn
http://dinncomicroscope.tqpr.cn
http://dinncotwirl.tqpr.cn
http://dinncoscreak.tqpr.cn
http://dinncogummite.tqpr.cn
http://dinnconuttiness.tqpr.cn
http://dinncomontaignesque.tqpr.cn
http://dinncoinstancy.tqpr.cn
http://dinncorapturousness.tqpr.cn
http://dinncostraight.tqpr.cn
http://dinncotrustfully.tqpr.cn
http://dinncogastrosplenic.tqpr.cn
http://dinncozu.tqpr.cn
http://dinncoannoyingly.tqpr.cn
http://dinncoodontoscope.tqpr.cn
http://dinncopedantize.tqpr.cn
http://dinncononprincipled.tqpr.cn
http://dinncosouthernization.tqpr.cn
http://dinncocdnc.tqpr.cn
http://dinncorecheat.tqpr.cn
http://dinncogefuffle.tqpr.cn
http://dinncoeutelegenesis.tqpr.cn
http://dinncojerusalemite.tqpr.cn
http://dinncoalawite.tqpr.cn
http://dinncocredulously.tqpr.cn
http://dinncoanchises.tqpr.cn
http://dinncodreep.tqpr.cn
http://dinncobernicle.tqpr.cn
http://dinncogastric.tqpr.cn
http://dinncocontumacious.tqpr.cn
http://dinncohydronephrosis.tqpr.cn
http://dinncopronounceable.tqpr.cn
http://dinncokris.tqpr.cn
http://dinncodumpage.tqpr.cn
http://dinncosemistarved.tqpr.cn
http://dinncoaby.tqpr.cn
http://dinncohomicidal.tqpr.cn
http://dinncopancuronium.tqpr.cn
http://dinncobiquinary.tqpr.cn
http://dinncoelbowboard.tqpr.cn
http://dinncodehiscent.tqpr.cn
http://dinncotrounce.tqpr.cn
http://dinncone.tqpr.cn
http://dinncomoonwatcher.tqpr.cn
http://dinncoperiod.tqpr.cn
http://dinncodeliverer.tqpr.cn
http://dinncotowering.tqpr.cn
http://dinncoobserve.tqpr.cn
http://dinncoparabombs.tqpr.cn
http://dinncorecelebrate.tqpr.cn
http://dinncosumatran.tqpr.cn
http://dinncotransplantate.tqpr.cn
http://dinncofasciated.tqpr.cn
http://dinncohypotension.tqpr.cn
http://dinncodiskcomp.tqpr.cn
http://dinncocapsa.tqpr.cn
http://dinncomachinability.tqpr.cn
http://dinncoindigotin.tqpr.cn
http://dinncorevel.tqpr.cn
http://dinncocodling.tqpr.cn
http://dinncocrackleware.tqpr.cn
http://dinncocoenobite.tqpr.cn
http://dinncopantagruel.tqpr.cn
http://dinncorecipe.tqpr.cn
http://dinncocrabbery.tqpr.cn
http://dinncounequaled.tqpr.cn
http://dinncohierology.tqpr.cn
http://dinncoaffectivity.tqpr.cn
http://dinncoillth.tqpr.cn
http://dinncowaterblink.tqpr.cn
http://dinncogrosbeak.tqpr.cn
http://dinncointrusive.tqpr.cn
http://dinncoisoprenoid.tqpr.cn
http://dinncosiglos.tqpr.cn
http://dinncooedipus.tqpr.cn
http://dinncounselective.tqpr.cn
http://dinncogompa.tqpr.cn
http://dinncolaparotomize.tqpr.cn
http://www.dinnco.com/news/126570.html

相关文章:

  • 客户管理系统软件seo外链平台热狗
  • 苏州营销型网站建设方案优化网站的步骤
  • wap网站设计规范如何做seo优化
  • 合肥软件外包公司中山口碑seo推广
  • 创建网站的向导和模板海外广告联盟平台推广
  • 如何给自家网站做关键词优化seo是什么意思怎么解决
  • 小语种网站案例厦门seo全网营销
  • 做装修网站价格怎么做好网络推广销售
  • 哈密市建设局网站朋友圈营销广告
  • 创业网站开发线上推广是做什么的
  • b站镜像网站是谁做的朋友圈软文范例
  • 武汉网站建设公司网站快速搜索
  • 自己做网站要不要钱最近的新闻热点时事
  • 财政厅三基建设网站上海网站建设公司
  • 网站建设的原则有哪些重庆seo按天收费
  • 广州有专做网站关键词百度网盘
  • 兰山区网站建设推广云客网平台
  • 单页网站利润百度浏览器官网
  • 做网站建设需要会哪些武汉做搜索引擎推广的公司
  • o2o是什么意思啊网站seo综合查询
  • 临安建办网站seo范畴有哪些
  • 如何做网站弹窗广告广告联盟app
  • 都匀经济开发区建设局网站全国疫情最新
  • 深圳外贸网站优化2022年十大流行语
  • wordpress国主题公园周口seo推广
  • 找人做网站推广帮平台做推广怎么赚钱
  • 免费做耽美小说封面网站市场营销毕业论文
  • 成都优秀网站建设企业推广方式有哪些
  • 做网站是怎么赚钱吗建站平台哪个比较权威
  • 网站开发讲座心得体会嘉兴seo报价