相关疑难解决方法(0)

es2015模块-如何动态命名导出

在此示例react-hyperscript中,该方法是咖喱的,并公开了一组默认函数,因此h('div', props, children)变为div(props, children)

import hyperscript from 'react-hyperscript';
import {curry} from 'lodash';

const isString = v => typeof v === 'string' && v.length > 0;
const isSelector = v => isString(v) && (v[0] === '.' || v[0] === '#');

const h = curry(
  (tagName, first, ...rest) =>
    isString(tagName) && isSelector(first) ?
      hyperscript(tagName + first, ...rest) :
      hyperscript(tagName, first, ...rest)
);

const TAG_NAMES = [
  'a', 'abbr', 'address', 'area', 'article', 'aside', 'audio', 'b', 'base', // …
Run Code Online (Sandbox Code Playgroud)

javascript module ecmascript-6

2
推荐指数
1
解决办法
1247
查看次数

标签 统计

ecmascript-6 ×1

javascript ×1

module ×1