react中函数调用方法

2019-02-20  本文已影响5人  说不出口的喵

方式一:内联调用法

import React, { Component }from 'react';

class funcextends Component{

constructor(porps){

super(props);

  }

funcOne(){

console.log('内联调用法')

}

render(){

return (

  )

}

}

方式二:配置中调用法

import React, { Component }from 'react';

class funcextends Component{

constructor(porps){

super(props);

    this.funcTwo =this.funcTwo.bind(this)

}

funcTwo(){

console.log('配置中调用法')

}

render(){

return (

  )

}

}

方式三:箭头函数调用法(最推荐)import React, { Component }from 'react';

class funcextends Component{

constructor(porps){

super(props);

  }

funcThree:() => {

console.log('箭头函数调用法')

}

render(){

return (

  )

}

}

上一篇 下一篇

猜你喜欢

热点阅读