一个简单的例子在这里:
http://tjholowaychuk.tumblr.com/post/37832588021/building-a-date-picker-component
我跟着做了一下,有点问题,找不到依赖的库。不过 github 上的代码好用。
昨天试了一个进展条的component
http://blog.kewah.com/2014/build-a-web-app-with-component/
也是出错。命令行的结果和blog里的不太一样。东西比较新,更新太快。
Component(1) is a front-end package manager created by TJ Holowaychuk. It embraces the philosophy of creating small and reusable modules. It is not restricted to JavaScript, indeed we are able to create components that also contain CSS, HTML, JSON, images, fonts, … Therefore we can create JavaScript libraries, UI component or reusable CSS utility classes. It allows us to organize applications around multiple components.
进展条例子中读template有问题,改成内置字符串可暂时解决出错问题:
//var template = require('./template.html');
var template =
'<div class="progressBar">' +
'<div class="progressBar-percent js-percentBar"></div>' +
'</div>';
可以用 browserify + component + brfs