React Canvas:高性能渲染 React 组
生活随笔
收集整理的這篇文章主要介紹了
React Canvas:高性能渲染 React 组
小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
React Canvas 提供了使用 Canvas 渲染移動(dòng) Web App 界面的能力,替代傳統(tǒng)的 DOM 渲染,具有更接近 Native App 的使用體驗(yàn)。React Canvas 提供了一組標(biāo)準(zhǔn)的 React 組件,由基于的渲染元素抽象而成。
?
?
?
GitHub? ? ??源碼下載
示例代碼:
var React = require('react'); var ReactCanvas = require('react-canvas');var Surface = ReactCanvas.Surface; var Image = ReactCanvas.Image; var Text = ReactCanvas.Text;var MyComponent = React.createClass({render: function () {var surfaceWidth = window.innerWidth;var surfaceHeight = window.innerHeight;var imageStyle = this.getImageStyle();var textStyle = this.getTextStyle();return (<Surface width={surfaceWidth} height={surfaceHeight} left={0} top={0}><Image style={imageStyle} src='...' /><Text style={textStyle}>Here is some text below an image.</Text></Surface>);},getImageHeight: function () {return Math.round(window.innerHeight / 2);},getImageStyle: function () {return {top: 0,left: 0,width: window.innerWidth,height: this.getImageHeight()};},getTextStyle: function () {return {top: this.getImageHeight() + 10,left: 0,width: window.innerWidth,height: 20,lineHeight: 20,fontSize: 12};}});您可能感興趣的相關(guān)文章
- 網(wǎng)站開發(fā)中很有用的 jQuery 效果【附源碼】
- 分享35個(gè)讓人驚訝的 CSS3 動(dòng)畫效果演示
- 十分驚艷的8個(gè) HTML5 & JavaScript 特效
- Web 開發(fā)中很實(shí)用的10個(gè)效果【源碼下載】
- 12款經(jīng)典的白富美型 jQuery 圖片輪播插件
?
本文鏈接:React Canvas:高性能渲染 React 組件
編譯來(lái)源:夢(mèng)想天空 ◆ 關(guān)注前端開發(fā)技術(shù) ◆ 分享網(wǎng)頁(yè)設(shè)計(jì)資源
轉(zhuǎn)載于:https://www.cnblogs.com/lhb25/p/react-canvas-high-performance-rendering.html
總結(jié)
以上是生活随笔為你收集整理的React Canvas:高性能渲染 React 组的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: 精通android(Pro Androi
- 下一篇: Flex 序列化自定义类 解决 shar