index.wxml 910 B

1234567891011121314151617181920212223242526
  1. <view class="i-class i-switch {{parse.setSize(size)}} {{parse.setCurrent(value,disabled)}}" bindtap="toggle">
  2. <input type="text" :name="name" wx:value="{{value}}" class="i-switch-hide-input"></input>
  3. <view class="i-switch-inner" wx:if="{{value === true}}">
  4. <slot name="open"></slot>
  5. </view>
  6. <view class="i-switch-inner" wx:else>
  7. <slot name="close"></slot>
  8. </view>
  9. </view>
  10. <wxs module="parse">
  11. var sizes = ['large', 'default'];
  12. var prefixCls = 'i-switch';
  13. module.exports = {
  14. setSize : function( size ){
  15. var index = sizes.indexOf( size );
  16. return prefixCls + ( index > -1 ? ( '-'+size ) : 'default' )
  17. },
  18. setCurrent : function( value,disabled ){
  19. var className = value && !disabled ? prefixCls + '-checked' : '';
  20. if( disabled ){
  21. className += ' ' + prefixCls + '-disabled';
  22. }
  23. return className;
  24. }
  25. }
  26. </wxs>