react學習中的一些細節

2021-08-27 07:54:00 字數 1279 閱讀 5646

1、css相關

react的css引用方式:

var styles = require(「./category.css」);

import styles from 「./category.css」;

傳統的方式是

元件的使用方式:

test

傳統的方式是test

要使用兩個類,classname =

想使用行內樣式,就是這樣的寫法:

test

或者var styles =

test

2、元件生命週期函式

mounting:

getdefaultprops();

getinitialstate();

componentwillmount();

render();

componentdid

mount

();updating:

componentwillreceiveprops();

shouldcomponentupdate();

componentwillupdate();

render();

componentdidupdate();

3、react中常用的es6寫法總結

模組部分

匯入:    

import 「模組url」;

import 元件 from 「元件模組url」;

匯出:export default class mycomponent extends component

import mycomponent form 「./mycomponent」;

定義元件部分

class mycomponent extends component }

定義元件屬性型別和預設屬性

class mycomponent extends component;

static proptypes = ;

render()

}

初始化state

class video extends react.component; }

}4、react的子元件向父元件傳值,本質上就是把父元件的屬性當作函式來處理

父元件:

子元件:

通過時間來呼叫this.props.onclickevent(引數);

**方式為:

handleevent()

rosbag中的一些細節

將執行的ros軟體上的資料記錄到乙個.bag檔案,然後重放資料再產生相同的效果。1.記錄資料 建立乙個bag檔案 從乙個執行的ros系統中記錄topic的資料,這個topic資料會在乙個bag檔案中積累。roscore rosrun turtlesim turtlesim node rosrun t...

SeekBar Seekbar中的一些細節要點

1.修改seekbar中進度條的高度 android maxheight和android minheight 前者是用來指定進度條最大高度的 此高度並非seekbar整個控制項的高度 後者是用來指定最小高度,一般將這兩個屬性值設定成一致即可。2.滑塊和背景之間有截斷的問題 android thumb...

React 有關樣式,有關JSX的一些細節

jsx中的注釋要寫成js 段的形式。大括號。編寫樣式的時候,jsx中標籤的class屬性會和react原有的class屬性造成衝突。雖然不影響執行,但改為classname 的形式更好。我們接受一些後端發來的資料進行dom操作的時候,會用到dangerouslysetinnerhtml取消對指令的轉...