Skip to content

Instantly share code, notes, and snippets.

View luokailuo's full-sized avatar
👋
K

罗开罗 luokailuo

👋
K
View GitHub Profile
@luokailuo
luokailuo / react-create-table-component
Last active May 13, 2020 06:16
React动态生成table
/**
* 引用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;
@luokailuo
luokailuo / react-spread-attitudes
Created March 28, 2016 03:20
“...props”属性扩散的使用
/**
* 有时候需要给组件设置多个props,却又不想一个个写下这些属性,此时react的spread attitudes功能就能派上用场了
*/
export default class UserManagement extends React.Component{
render() {
var users = {};
users.name = 'richard';
users.age = 23;
users.phone = 18898552252;
@luokailuo
luokailuo / Javascript-Array-Loop
Created April 8, 2016 03:14
Javascript数组遍历注意事项
for(var i=0, i_len = arr.length; i<i_len; i++){
// do something
}
@luokailuo
luokailuo / JS-Determine-WeChatBrowser
Last active April 11, 2016 02:23
Javascript 判断是否微信内置浏览器
/* 判断 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;
}
@luokailuo
luokailuo / jQuery-bottom-to-top
Last active April 18, 2016 07:00
Web开发的10个jQuery代码片段
// 平稳滑动返回到页面顶部
//html
<a id="toTop" href="#">to top</a>
//jQuery
<script>
$("#toTop").click(function() {
$("html, body").animate({ scrollTop: 0 }, "slow");
@luokailuo
luokailuo / JS-20-RegExp
Created April 27, 2016 02:43
20个正则表达式
1.check password strength
//密码的强度必须是包含大小写字母和数字的组合,不能使用特殊字符,长度在8-10之间
-----------------------
^(?=.*\\d)(?=.*[a-z])(?=.*[A-Z]).{8,10}$
-----------------------
2.check chinese
//字符串仅能是中文
-----------------------
@luokailuo
luokailuo / array-sort-date
Last active May 17, 2016 07:30
利用sort()方法对Array进行日期时间排序
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){
@luokailuo
luokailuo / 用JavaScript将数字转换为大写金额
Created May 26, 2016 00:01
用JavaScript将数字转换为大写金额
var digitUppercase = function(n) {
var fraction = ['角', '分'];
var digit = [
'零', '壹', '贰', '叁', '肆',
'伍', '陆', '柒', '捌', '玖'
];
var unit = [
['元', '万', '亿'],
['', '拾', '佰', '仟']
];