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
/** | |
* 引用React | |
*/ | |
import React from 'react'; | |
var DOM = React.DOM; | |
var table = DOM.table; | |
var tbody = DOM.tbody; | |
var tr = DOM.tr; | |
var td = DOM.td; |
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
/** | |
* 有时候需要给组件设置多个props,却又不想一个个写下这些属性,此时react的spread attitudes功能就能派上用场了 | |
*/ | |
export default class UserManagement extends React.Component{ | |
render() { | |
var users = {}; | |
users.name = 'richard'; | |
users.age = 23; | |
users.phone = 18898552252; |
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
for(var i=0, i_len = arr.length; i<i_len; i++){ | |
// do something | |
} |
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
/* 判断 window.navigator.userAgent 中是否含有关键字:micromessenger */ | |
function isWeiXinBrowser() { | |
var ua = window.navigator.userAgent.toLowerCase(); | |
console.log(ua); | |
if (ua.match(/MicroMessenger/i) == 'micromessenger') { | |
return true; | |
} else { | |
return false; | |
} |
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
// 平稳滑动返回到页面顶部 | |
//html | |
<a id="toTop" href="#">to top</a> | |
//jQuery | |
<script> | |
$("#toTop").click(function() { | |
$("html, body").animate({ scrollTop: 0 }, "slow"); |
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.check password strength | |
//密码的强度必须是包含大小写字母和数字的组合,不能使用特殊字符,长度在8-10之间 | |
----------------------- | |
^(?=.*\\d)(?=.*[a-z])(?=.*[A-Z]).{8,10}$ | |
----------------------- | |
2.check chinese | |
//字符串仅能是中文 | |
----------------------- |
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
var data = get_data(); | |
//降序 | |
data.sort( function(a, b){ | |
return a["createAt" ] < b["createAt" ] ? 1 : a["createAt" ] == b["createAt" ] ? 0 : -1; | |
}); | |
//升序 | |
data.sort( function(a, b){ |
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
var digitUppercase = function(n) { | |
var fraction = ['角', '分']; | |
var digit = [ | |
'零', '壹', '贰', '叁', '肆', | |
'伍', '陆', '柒', '捌', '玖' | |
]; | |
var unit = [ | |
['元', '万', '亿'], | |
['', '拾', '佰', '仟'] | |
]; |