当前位置: 首页 > 文档资料 > Feui 中文文档 >

Checker 选择按钮

优质
小牛编辑
140浏览
2023-12-01
import { Checker,CheckerItem } from 'feui';
components: {
  [Checker.name]: Checker,
  [CheckerItem.name]: CheckerItem
},
data () {
  return {
    items1: [
        {
          key: "1",
          value: "A"
        },
        {
          key: "2",
          value: "B"
        },
        {
          key: "3",
          value: "C"
        }
      ],
      demo1: "",
      demo2: "2",
      demo3: "",
      demo4: '云和天',
      showPopup: false,
      demo5: 1,
      demo6: [2, 3],
  }
},
methods:{
  onItemClick (value, disabled) {
    console.log(value, disabled)
    if (!this.disabled) {
      this.showPopup = false
    }
  }
}

代码演示

基础用法

<fe-checker v-model="demo1" 
 default-item-class="demo1-item" 
 selected-item-class="demo1-item-selected">
   <fe-checker-item value="1">壹</fe-checker-item>
   <fe-checker-item value="2">貮</fe-checker-item>
   <fe-checker-item value="3">叁</fe-checker-item>
   <fe-checker-item value="4">肆</fe-checker-item>
   <fe-checker-item value="5">伍</fe-checker-item>
 </fe-checker>

自定义样式

<fe-checker v-model="demo3" 
  default-item-class="demo3-item" 
  selected-item-class="demo3-item-selected">
  <fe-checker-item value="FD6E0E">
    <img src="http://temp.im/80x45/FD6E0E/ffffff" alt="">
  </fe-checker-item>
  <fe-checker-item value="e71e18">
    <img src="http://temp.im/80x45/E71E18/ffffff" alt="">
  </fe-checker-item>
  <fe-checker-item value="453221">
    <img src="http://temp.im/80x45/45322E/ffffff" alt="">
  </fe-checker-item>
</fe-checker>

使用弹出层

<fe-group>
  <fe-cell title="选择套餐" :value="demo4" is-link 
  @click.native="showPopup=true"></fe-cell>
</fe-group>
<div v-transfer-dom>
  <fe-popup v-model="showPopup" class="checker-popup">
    <div style="padding:10px 10px 40px 10px;">
      <p style="padding: 5px 5px 5px 2px;color:#888;">选择套餐</p>
      <fe-checker
      v-model="demo4"
      default-item-class="demo4-item"
      selected-item-class="demo4-item-selected"
      disabled-item-class="demo4-item-disabled">
        <fe-checker-item value="云和天" @on-item-click="onItemClick">
          云和天</fe-checker-item>
        <fe-checker-item value="蝶和花" @on-item-click="onItemClick">
          蝶和花</fe-checker-item>
        <fe-checker-item value="我和你" @on-item-click="onItemClick">
          我和你</fe-checker-item>
        <fe-checker-item value="全家福" disabled @on-item-click="onItemClick">
          全家福</fe-checker-item>
      </fe-checker>
    </div>
  </fe-popup>
</div>

常见demo单选

<fe-checker
  v-model="demo5"
  default-item-class="demo5-item"
  selected-item-class="demo5-item-selected"
  >
  <fe-checker-item v-for="i in [1, 2, 3]" :key="i" 
  :value="i">¥{{i*300}}</fe-checker-item>
</fe-checker>

常见demo单选

<fe-checker
  v-model="demo6"
  type="checkbox"
  default-item-class="demo5-item"
  selected-item-class="demo5-item-selected"
>
  <fe-checker-item v-for="i in [1, 2, 3]" :key="i" 
    :value="i">{{['good', 'nice','awesome'][i - 1]}}
  </fe-checker-item>
</fe-checker>

Checker API

参数说明类型默认值可选值
value表单值,使用v-model绑定NumberArray--
type类型,单选为radio, 多选为checkboxStringradio-
max最多可选个数,多选时可用Number--
radio-required在单选模式下是否必选一个值。设为 true 后点击当前选中项不会取消选中。Booleanfalsetrue,false
default-item-class表单值String--
selected-item-class标题String--
disabled-item-class是否必选Stringfalsetrue,false
-----


Events

事件名参数说明备注
on-changevalue值变化时触发-
----


CheckerItem API

参数说明类型默认值可选值
value当前项的值String--
disabled是否为不可选Booleanfalsetrue,false
-----


Events

事件名参数说明备注
@on-item-clickitemValue, itemDisabled当前项被点击时触发-
----