Skip to content

Instantly share code, notes, and snippets.

@hzq1988a
hzq1988a / selectUser.js
Created August 9, 2017 10:00
函数包装方式的弹出框逻辑
export default function (label = '加签'){
let container = document.createElement('div')
document.body.appendChild(container)
let isDestroy = false;
var instance = null;
return new Promise(function(resolve, reject){
function removeDom(){
if(!isDestroy && instance){
instance.setState({
visible:false,
@hzq1988a
hzq1988a / memoizePromise.js
Created June 20, 2017 06:37
可以缓存promise结果的辅助函数
export var memoizePromise = function(fun){
var cache = {};
return function(...args){
var key = args.toString();
return new Promise(function(resolve, reject){
if(cache[key]){
return resolve(cache[key])
}else{
fun.apply(this, args).then((data)=>{
cache[key] = data;
@hzq1988a
hzq1988a / exchange.js
Last active June 16, 2017 08:54 — forked from tonyc726/exchange.js
JS数字金额大写转换
var digitUppercase = function(n) {
var fraction = ['角', '分'];
var digit = [
'零', '壹', '贰', '叁', '肆',
'伍', '陆', '柒', '捌', '玖'
];
var unit = [
['元', '万', '亿'],
['', '拾', '佰', '仟']
];
@hzq1988a
hzq1988a / 0_reuse_code.js
Last active August 29, 2015 14:13
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
class test{
public function __contruct(){
}
}