[Flux] Component / Views
The application will dislay a some catalogs, and each catalog has title image, description.
Catalog:
import React from 'react';
import AppStore from '../stores/app-store';
import CatalogItem from './app-catalogitem'; function getCatalog(){
return { items: AppStore.getCatalog() }
} class Catalog extends React.Component {
constructor(){
super();
this.state = getCatalog()
}
render(){
let items = this.state.items.map( item => {
return <CatalogItem key={ item.id } item={ item } />
});
return (
<div className="row">
{ items }
</div>
)
}
}
export default Catalog;
Each Catalog render CatalogItem:
import React from 'react';
import AppActions from '../actions/app-actions';
import CartButton from './app-cart-button'; export default (props) => {
return (
<div className="col-xs-6 col-sm-4 col-md-3">
<h4>{ props.item.title }</h4>
<img src="http://placehold.it/250x250" width="100%" className="img-responsive"/>
<p>{ props.item.summary }</p>
<p>${ props.item.cost }</p>
<CartButton
handler={
AppActions.addItem.bind(null, props.item)
}
txt="Add To Cart"
/>
</div>
)
}
CartButton handle the click event whcih passed in:
import React from 'react';
export default (props) => {
return (
<button
className="btn btn-default btn-sm"
onClick={ props.handler }>
{ props.txt }
</button>
)
}
[Flux] Component / Views的更多相关文章
- Photon自定义加载Resource之外的资源
PhotonNetwork.cs 结尾添加如下代码: #region >>> Photon自定义异步加载GameObject public delegate void CustomL ...
- [译] 关于 Angular 依赖注入你需要知道的
如果你之前没有深入了解 Angular 依赖注入系统,那你现在可能认为 Angular 程序内的根注入器包含所有合并的服务提供商,每一个组件都有它自己的注入器,延迟加载模块有它自己的注入器. 但是,仅 ...
- 桌面应用开发之WPF页面导航
先看效果图 Get Start 为了项目解耦,使用mvvmlight框架.MVVM设计模式请自行了解. 1 新建项目 新建一个MvvmLight(WPF)项目,删除其中无关文件夹:Design ...
- java的图形界面初学惯用
1.单一界面的创建 public void mainFrame() { HashMap<String, Component> views = new HashMap<String, ...
- WPF MvvmLight简单实例(1) 页面导航
原文:WPF MvvmLight简单实例(1) 页面导航 实现了那些功能,先看看截图: 操作描述: 在程序运行后,点击“Load”按钮,页面会加载PageOne,点击PageOne页面中的“Next” ...
- 浅入深出Vue:自动化路由
在软件开发的过程中,"自动化"这个词出现的频率是比较高的.自动化测试,自动化数据映射以及各式的代码生成器.这些词语的背后,也说明了在软件开发的过程中,对于那些重复.千篇一律的事情. ...
- [codeigniter4]Upgrading from 3.x to 4.x
CodeIgniter 4 is a rewrite of the framework, and is not backwards compatible. It is more appropriate ...
- 国产深度学习框架mindspore-1.3.0 gpu版本无法进行源码编译
官网地址: https://www.mindspore.cn/install 所有依赖环境 进行sudo make install 安装,最终报错: 错误记录信息: cat /tmp/mind ...
- [Vue warn]: Unknown custom element: <sapn> - did you register the component correctly? For recursive components, make sure to provide the "name" option. found in ---> <Evaluate> at src/views/index/
关于vue报错: [Vue warn]: Unknown custom element: <sapn> - did you register the component correctly ...
随机推荐
- jQuery常用技巧大放送
1.关于页面元素的引用 通过jquery的$()引用元素包括通过id.class.元素名以及元素的层级关系及dom或者xpath条件等方法,且返回的对象为jquery对象(集合对象),不能直接调用do ...
- Jsoup库 解析DOM文档
DOM文档包括 HTML, XML等等 下载: http://jsoup.org/download Jsoup 获取数据的方式 //html 文本, url, 本地html String html = ...
- BZOJ 1015 星球大战
Description 很久以前,在一个遥远的星系,一个黑暗的帝国靠着它的超级武器统治者整个星系.某一天,凭着一个偶然的机遇,一支反抗军摧毁了帝国的超级武器,并攻下了星系中几乎所有的星球.这些星球通过 ...
- DOM this, currentTarget, Target
http://www.w3cmm.com/javascript/this-currenttarget-target.html about mvc this one is not recommend: ...
- iOS 16进制颜色和UIcolor的转换
各种颜色之间的转换,会陆续更新, 实现了 16进制颜色(HEX).RGBA.HSBA.UIColor之间的 相互转换 使用示例(加号方法,类名调用) //UIColor 转 RGB.HSB RGBA ...
- 大众点评试水O2O新模式:实体店试穿,扫描二维码付款 现场取货
在餐饮美食行业取得不错的成绩之后,大众点评将触角延伸到了线下的传统商铺,开始涉足线下商品的 O2O 团购.和传统的线上下单,线下消费的 O2O 模式不同.大众点评的 O2O 团购用户,可在店内试穿后通 ...
- 【面试&笔试】ASP.NET的相关问题
1. 介绍ASP.NET 答:ASP.NET不是一种语言,而是创建动态web页的一种强大的服务器端技术,它是Microsoft.NETFramework中一套用于生成Web应用程序和Web服 ...
- bzoj2427
一开始读错题导致各种不会做,无奈其实是一道水题,缩点反向建图树形dp即可 type link=^point; point=record po:longint; next:link; end; ..] ...
- [转] 关于C++中模板中的typename和class的区别比较
C++箴言:理解typename的两个含义 转自http://blog.csdn.net/dick_china/article/details/4522253 问题:在下面的 template dec ...
- [Locked] Walls and Gates
Walls and Gates You are given a m x n 2D grid initialized with these three possible values. -1 - A w ...