看 flux 官网的文档还是有些云里雾里的,需要一个 demo 来帮助在实践中进行理解,果断要选择 todomvc。
todomvc 已经有了各种各样框架的实现版本,在 flux 官方仓库中也提供了 tomomvc 的 flux� 版本,拿它作为入门学习 flux 的 demo 是相当不错的。
本文仅仅使用 todomvc 作为一个例子来说明,不会对其进行具体的代码解析。
function _isSupportInputDate() { | |
var input = document.createElement('input') | |
input.type = 'date' | |
input.value = 'test' // input[type=date] can't set value as a string. | |
return input.value !== 'date' | |
} |
关于 Riot 的 compiler,具体请见:[Riot compiler]
之前在 [Riot 源码阅读笔记] 中提到另挖坑来聊聊 Riot 提供的 template + logic
compiler 是怎么干活的,于是有了这一篇文章... (其实大部分都是正则,正则)
Riot 提供了两种方式,分别是 pre-compile
和直接在页面使用 script[type="riot/tag"]
,都是用的同一个 compiler 来处理代码的解析,在真实环境时推荐使用 pre-compile
的方式。
在页面使用 script[type="riot/tag", src="path"] 和 React 在页面使用 script[type="text/jsx", src="path"] 一样,都是用了 ajax 来请求文件内容,跨域就拜拜了,请知悉。
第一次看到 Riot,感觉就是惊艳。我对 React 不大了解,只是简单知道一些,所以在我看来,React 实现的一些东西,Riot 也可以实现,而且代码精简,麻雀虽小,五脏俱全,可以用很简单的语法创建类似 web component
的自定义标签,渲染的性能好像还不赖。
注:不支持自定义标签的浏览器需要手动创建标签,如 [demo/index.html]
cat /dev/urandom | head -1 | md5sum | cut -c 1-16 |