1.0.0-beta.1 • Published 6 years ago

rax-checkbox v1.0.0-beta.1

Weekly downloads
1
License
BSD-3-Clause
Repository
-
Last release
6 years ago

CheckBox 选择框

CheckBox 是基础的选择框,选择框用图片实现,支持用户使用自己的图片进行替换

npm.io

安装

$ npm install rax-checkbox --save

引用

import CheckBox from "rax-checkbox";

属性

名称类型默认值描述
defaultCheckedBoolean默认选中状态
checkedBoolean选中状态
checkedImageString选中图片
uncheckedImageString非选中图片
containerStyleObject选择框容器样式
checkboxStyleObject选择框图片样式
onChangeFunction选择事件

基本示例

// demo
/** @jsx createElement */
'use strict';
import { createElement, render, useState } from 'rax';
import DU from 'driver-universal';
import Checkbox from 'rax-checkbox';
import View from 'rax-view';
import Text from 'rax-text';

const App = () => {
  const [checked, setChecked] = useState(false);
  const [controlledCheckboxMsg, setControlledCheckboxMsg] = useState('');
  const [unControlledCheckboxMsg, setUncontrolledCheckboxMsg] = useState('');
  return (
    <View>
      <Text>Controlled: {controlledCheckboxMsg}</Text>
      <Checkbox
        checked={checked}
        onChange={hasChecked => {
          setControlledCheckboxMsg(`onChange => ${hasChecked}`);
        }}
      >{(value) => <Text>{value}</Text>}</Checkbox>
      <View
        style={{
          paddingLeft: 15,
          paddingRight: 15,
          backgroundColor: '#1890FF',
          width: 200,
          borderRadius: 15,
          alignItems: 'center',
          justifyContent: 'center'
        }}
        onClick={() => {
          setChecked(!checked);
        }}
      >
        <Text style={{ color: '#fff' }}>Click Me!</Text>
      </View>
      <Text>Uncontrolled: {unControlledCheckboxMsg}</Text>
      <Checkbox
        defaultChecked
        onChange={(hasChecked) => {
          setUncontrolledCheckboxMsg(`onChange => ${hasChecked}`);
        }}
      >{(value) => (<Text>{value}</Text>)}</Checkbox>
    </View>
  );
};

render(<App />, document.body, {
  driver: DU
});
1.1.0-1

6 years ago

1.1.0-0

6 years ago

1.0.0-0

6 years ago

1.0.0-beta.2

6 years ago

1.0.0-beta.1

6 years ago

0.6.5

7 years ago

0.6.4

7 years ago

0.6.3

7 years ago

0.6.2

7 years ago

0.6.0

7 years ago

0.5.4

7 years ago

0.5.2

7 years ago

0.5.1

7 years ago

0.5.0

8 years ago

0.4.20

8 years ago

0.4.19

8 years ago

0.4.18

8 years ago

0.4.17

8 years ago

0.4.16

8 years ago

0.4.15

8 years ago

0.5.0-beta

8 years ago

0.4.14

8 years ago

0.4.13

8 years ago

0.4.12

8 years ago

0.4.11

8 years ago

0.4.10

8 years ago

0.4.9

8 years ago

0.4.8

8 years ago

0.4.7

8 years ago

0.4.6

8 years ago

0.4.5

8 years ago

0.4.4

8 years ago

0.4.3

8 years ago

0.4.2

8 years ago

0.4.1

8 years ago

0.4.0

8 years ago

0.3.8

8 years ago

0.3.7

8 years ago

0.3.6

8 years ago

0.3.5

8 years ago

0.3.4

8 years ago

0.3.3

8 years ago

0.3.2

8 years ago

0.3.1

8 years ago

0.3.0

8 years ago