博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
[Cycle.js] Hello World in Cycle.js
阅读量:7202 次
发布时间:2019-06-29

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

Now you should have a good idea what Cycle.run does, and what the DOM Driver is. In this lesson, we will not build a toy version of Cycle.js anymore. Instead, we will learn how to use Cycle.js to solve problems. We will start by making a simple Hello world application.

 

const {label, input, hr, h1, div, makeDOMDriver} = CycleDOM;function main(sources) {    // Read from driver, select '.field' class bind with input event.  const inputEvent$ = sources.DOMM.select('.field').events('input');  // each input event will map to it's value  // Because at first there is no input, so we mock one by using startWith('')  const name$ = inputEvent$.map( ev => ev.target.value).startWith('');    return {    // Each name event will output the CycleDOM    DOMM: name$.map( name => {      return div([        label('Name: '),        input('.field',{type: 'text'}),        hr(),        h1(`Hello ${name}`)      ])    })   };}const drivers = {  DOMM: makeDOMDriver('#app')}Cycle.run(main, drivers);

 

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

你可能感兴趣的文章
模板特化疑问
查看>>
李京:中国科技大学移动平台——掌上科大
查看>>
<转>Windows下用xcode开发swift程序的图文教程 <一>
查看>>
PMCalendar
查看>>
【收藏】Aspose.Pdf应用教程
查看>>
PHP使用星号隐藏用户名,手机,邮箱的实现方法
查看>>
C++ 指针—01 指针与数组的对比
查看>>
推荐6款常用的Java开源报表制作工具
查看>>
CentOS mini安装环境下安装私有YUM服务器
查看>>
mysql case when 多参数条件语法
查看>>
iOS手势识别的详细使用(拖动,缩放,旋转,点击,手势依赖,自定义手势)
查看>>
实现JSON在线美化(格式化)、JSON转CSV、CSV转XML工具-toolfk程序员工具网
查看>>
Combine Two Tables[leetcode]
查看>>
Linux环境变量
查看>>
Python2 进程扫描脚本
查看>>
JQuery EasyUI 日期控件如何控制日期选择区间
查看>>
scrapy ImportError: No module named items
查看>>
jboss7.1.1配置jndi
查看>>
JSP里request变量列表
查看>>
#python#面向对象练手+模仿Amazon的物流追踪显示
查看>>