用md5处理文件名。引入md5
将文件处理成base64
驼峰命名处理
function cached(fn) { const cache = Object.create(null); return function cachedFn(str) { const hit = cache[str]; return hit || (cache[str] = fn(str)); }; } const regex = /-(w)/g; const camelize = cached(str => str.replace(regex, (_, c) => (c ? c.toUpperCase() : "")) );
例子:
const attributes = Object.keys(this.$attrs).reduce((res, key) => { res[camelize(key)] = this.$attrs[key]; return res; }, {})