江辰

博客

PhantomJS not found on PATH

发布于 # PhantomJS

今天 Win 上进行npm install的时候遇到一个问题 PhantomJS not found on PATH Downloading https://github.com/Medium/phantomjs/releases/download/v2.1.1/phantomjs-2.1.1-windows.zip Saving to C:\Users\hezhi\AppData\Local\Temp\phantomjs\phantomjs-2.1.1-windows.zip Receiving... [=---------------------------------------] 2% 这个 phantomjs-2.1.1-windows.zip 包一直下载不了,原来是天朝的网给墙了。 http://phantomjs.org/download.html 通过这个网址进行下载

阿里云 OSS 如何通过 Node.js 上传图片

发布于 # 阿里云

const multiparty = require('multiparty'); require('../../conf/util.js'); require('../../conf/oss.js'); const fs = require('fs'); const fsE = require('fs-extra'); global.router.put(`${global.api}uploadAvatar`, function (req, res) { let datas = {}; const { account, avatar } = req.session; if (!(fs.existsSync(global.location + account))) { fs.mkdir(global.loca

JS 实现 deepCopy

发布于 # JS

function getType(obj) { // 为啥不用typeof? typeof无法区分数组和对象 if(Object.prototype.toString.call(obj) == '[object Object]') { return 'Object'; } if(Object.prototype.toString.call(obj) == '[object Array]') { return 'Array'; } return 'nomal'; }; function deepCopy(obj) { if (getType(obj) == 'nomal') { return obj; } else { var newObj = getType(

Weex如何实现dialog

发布于 # Weex

<template> <div class="modal-wrapper" v-if="show"> <div class="modal-mask" /> <div class="dialog-box" :style="{top:top + 'px'}"> <slot /> <div class="dialog-footer" v-if="single"> <div class="footer-btn cancel" @click="secondaryClicked"> <text

Ant Design表格列拖拽,部分源码

发布于 # Ant Design

难点 如何与现有的自定义列、拖拽功能保持兼容。 如何与现有的代码和接口数据结构保持兼容。 拖动列宽的时候,如何阻止拖拽事件发生。 其他边缘情况。 源码 // 添加onmousedown事件和样式 const ResizeableTitle = (props) => { const { width, onMouseDown, index, ...restProps } = props; if(!width) { return <th {...restProps} />; } if(width.toString().indexOf('%') > -1) { return <th {...restProps} />; } const propsClassName = `${re