react typescript學習記錄

2021-10-01 20:49:20 字數 1078 閱讀 4668

1.hello world(第乙個例子)

import * as react from 'react'

class helloworld extends react.component

}export default helloworld

2.元素渲染

想要將乙個 react 元素渲染到根 dom 節點中,只需把它們一起傳入reactdom.render()

const element = ;

reactdom.render(element, document.getelementbyid('root'));

react 元素是不可變物件。一旦被建立,你就無法更改它的子元素或者屬性。乙個元素就像電影的單幀:它代表了某個特定時刻的 ui。

根據我們已有的知識,更新 ui 唯一的方式是建立乙個全新的元素,並將其傳入reactdom.render()

3.函式元件與 class 元件

​ 3.1 函式元件:

function welcome(props)
3.2 es6 的 class來定義元件:

class welcome extends react.component 

}

4.state & 生命週期

import * as react from 'react'

import dayjs from 'dayjs'

inte***ce props

inte***ce state

class helloworld extends react.component;

}

componentdidmount()

componentwillunmount()

tick() );

}

render()

}export default helloworld

React typescript下的 路徑別名配置

建立了乙個 typescript的 react專案 如果想在專案中引入元件等等 預設情況下這樣很難受 import mouse from components mouse 如果想要這樣的 import mouse from components mouse 該如何配置那 2.在專案根目錄新建conf...

tensorflow windows 學習記錄

1.python 版本3.7.1,安裝tensorflow.pip install tensorflow pip install numpy upgrade 2.檢視tensorflow 版本 進入python後 import tensorflow as tf tf.version 3.conda的...

ingress controller學習記錄

按文件操作 wgetwget 在service的spec中將nodeport固定一下。deploy demo.yaml的內容 結果 此時,訪問nodeip nodeport已經可以看到輸出,如圖 建立ingress root master ingress nginx kubectl get ingr...