This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// first component | |
var CommentBox = React.creatClass({ | |
render: function() { | |
return ( | |
<div className="commentBox"> | |
Hello, world! | |
</div> | |
); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 外观模式 | |
// | |
// 外观模式是一种很简单的模式,它只是为对象提供了更多的可供选择的接口。 | |
// 使方法保持短小而不是处理太多的工作是一种很好的实践。 | |
// 在这种实践的指导下,你会有一大堆的方法,而不是一个有着非常多参数的uber方法。 | |
// 有些时候,两个或者更多的方法会经常被一起调用。 | |
// 在这种情况下,创建另一个将这些重复调用包裹起来的方法就变得意义了。 | |
var myevent = { | |
// …… |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
app.factory('EventBus', function() { | |
var EventMap = []; | |
var EventBus = { | |
on: function(eventType, handler) { | |
if (!EventMap[eventType]) { | |
EventMap[eventType] = []; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 禁止iOS浏览器的橡皮筋效果,但是实例中会禁止掉链接的事件,也可以在body上加ontouchmove="event.preventDefault()" | |
$(document).ready(function(){ | |
function stopScrolling( touchEvent ) { | |
touchEvent.preventDefault(); | |
} | |
document.addEventListener( 'touchstart' , stopScrolling , false ); | |
document.addEventListener( 'touchmove' , stopScrolling , false ); | |
}); | |
//判断是否为android,BlackBerry,ios,windows |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 禁止iOS浏览器的橡皮筋效果,但是实例中会禁止掉链接的事件,也可以在body上加ontouchmove="event.preventDefault()" | |
$(document).ready(function(){ | |
function stopScrolling( touchEvent ) { | |
touchEvent.preventDefault(); | |
} | |
document.addEventListener( 'touchstart' , stopScrolling , false ); | |
document.addEventListener( 'touchmove' , stopScrolling , false ); | |
}); | |
//判断是否为android,BlackBerry,ios,windows |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 1 | |
var htmlSurpriseTab = [ | |
'<div>', | |
'<button id="lucky-draw">Lucky Draw</button>', | |
'</div>' | |
].join(''); | |
// 2 | |
actionList[actionName] && actionList[actionName].call(this,event); |