博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
React Canvas:高性能渲染 React 组
阅读量:7241 次
发布时间:2019-06-29

本文共 1095 字,大约阅读时间需要 3 分钟。

  React Canvas 提供了使用 渲染移动 Web App 界面的能力,替代传统的 渲染,具有更接近 Native App 的使用体验。React Canvas 提供了一组标准的 React 组件,由基于的渲染元素抽象而成。

 

 

 

      

 

示例代码:

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 (      
Here is some text below an image.
); }, 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 }; }});

  

您可能感兴趣的相关文章

 

本文链接:

编译来源:

转载地址:http://ztrfm.baihongyu.com/

你可能感兴趣的文章
java值传递
查看>>
解释Eclipse下Tomcat项目部署路径问题(.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps)...
查看>>
40个Java多线程问题总结
查看>>
DBImport v3.5 中文版发布:数据库定时同步及文档生成工具(IT人员必备)
查看>>
020-添加用户
查看>>
023-手动增加swap分区
查看>>
20.27 分发系统介绍
查看>>
Java进阶(一)使用new Date()和System.currentTimeMillis()获取当前时间戳
查看>>
推荐引擎
查看>>
Java字符串常亮池
查看>>
如何学习区块链
查看>>
华为加班有多可怕?
查看>>
灵活强大的MySQL代理中间件ProxySQL应用实战(1)
查看>>
Python项目实战:批量下载高清美图
查看>>
AIDL的实现
查看>>
OSChina 周三乱弹 —— 领导,请尊重我的专业!我不要再搬砖了!!!
查看>>
OSChina 周五乱弹 ——落落酱给你们发中秋礼品啦
查看>>
OSChina 周三乱弹 —— 听说分手以后你到处说我死了
查看>>
jQuery AJAX
查看>>
数据库日志收缩
查看>>