1.0.2 • Published 4 years ago

react-with-directive v1.0.2

Weekly downloads
4
License
ISC
Repository
github
Last release
4 years ago

react-with-directive,在react中注册使用指令

安装使用

npm i react-with-directive -S

注册指令

import { defineDirective } from 'react-with-directive'

/**
* name[string]: 指令名称,列如if
* options[shape({
*   install[func],
* })]: 配置参数
*/
defineDirective(name, options)

内置指令

如何使用

可以在组件或者普通元素上使用指令

<Demo
  r-if={flag}
  value={value}
  onchange={val => console.log(val)}
>
  <div
    r-class={{
      [style.active]: active,
      red: true,
    }}
  >Helloe Wolrd!
  </div>
</Demo>