1
在React組件中,如何渲染使用畫布創建的圖像?從React中的canvas context.getImageData渲染ImageData
componentWillMount() {
const canvas = document.createElement('canvas')
const context = canvas.getContext('2d')
canvas.width = 256
canvas.height = 256
// omitted canvas painting code
const image = context.getImageData(0, 0, canvas.width, canvas.height)
this.setState({image})
}
render() {
return ?
}