-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
232 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
let code = {}; | ||
|
||
code.import = ` | ||
"usingComponents": { | ||
"i-checkbox-group": "../../dist/checkbox-group/index", | ||
"i-checkbox": "../../dist/checkbox/index" | ||
} | ||
`; | ||
code.usage = ` | ||
<i-panel title="group-水果"> | ||
<i-checkbox-group current="{{current}}" bindchange="handleFruitChange"> | ||
<i-checkbox wx:for="{{fruit}}" position="{{position}}" wx:key="{{item.id}}" value="{{item.name}}"> | ||
</i-checkbox> | ||
</i-checkbox-group> | ||
</i-panel> | ||
<i-button bindclick="handleClick" type="ghost">切换复选框位置</i-button> | ||
<i-panel title="checkbox-动物"> | ||
<i-checkbox value="{{animal}}" disabled="{{disabled}}" checked="{{checked}}" bindchange="handleAnimalChange"> | ||
</i-checkbox> | ||
</i-panel> | ||
<i-button bindclick="handleDisabled" type="ghost">切换disabled状态</i-button> | ||
`; | ||
|
||
code.js = ` | ||
Page({ | ||
data: { | ||
fruit: [{ | ||
id: 1, | ||
name: '香蕉', | ||
}, { | ||
id: 2, | ||
name: '苹果' | ||
}, { | ||
id: 3, | ||
name: '西瓜' | ||
}, { | ||
id: 4, | ||
name: '葡萄', | ||
}], | ||
current: ['苹果', '葡萄'], | ||
position: 'left', | ||
animal: '熊猫', | ||
checked: false, | ||
disabled: false, | ||
}, | ||
handleFruitChange({ detail = {} }) { | ||
const index = this.data.current.indexOf(detail.value); | ||
index === -1 ? this.data.current.push(detail.value) : this.data.current.splice(index, 1); | ||
this.setData({ | ||
current: this.data.current | ||
}); | ||
}, | ||
handleClick() { | ||
this.setData({ | ||
position: this.data.position.indexOf('left') !== -1 ? 'right' : 'left', | ||
}); | ||
}, | ||
handleDisabled() { | ||
this.setData({ | ||
disabled: !this.data.disabled | ||
}); | ||
}, | ||
handleAnimalChange({ detail = {} }) { | ||
this.setData({ | ||
checked: detail.current | ||
}); | ||
}, | ||
}); | ||
`; | ||
|
||
export default code; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,150 @@ | ||
<template> | ||
<i-article> | ||
<article> | ||
<h1>Checkbox 复选</h1> | ||
<Anchor title="概述" h2></Anchor> | ||
<p>基本组件-多选框。主要用于一组可选项多项选择,或者单独用于标记切换某种状态。</p> | ||
<Anchor title="使用指南" h2></Anchor> | ||
<p>在 .json 中引入组件</p> | ||
<i-code bg lang="json">{{ code.import }}</i-code> | ||
<Anchor title="示例" h2></Anchor> | ||
<i-code bg lang="html">{{ code.usage }}</i-code> | ||
<br><br> | ||
<i-code bg lang="js">{{ code.js }}</i-code> | ||
<ad></ad> | ||
|
||
<div class="api"> | ||
<Anchor title="API" h2></Anchor> | ||
<Anchor title="CheckboxGroup properties" h3></Anchor> | ||
<table> | ||
<thead> | ||
<tr> | ||
<th>属性</th> | ||
<th>说明</th> | ||
<th>类型</th> | ||
<th>默认值</th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
<tr> | ||
<td>i-class</td> | ||
<td>自定义 class 类名</td> | ||
<td>String</td> | ||
<td>-</td> | ||
</tr> | ||
<tr> | ||
<td>current</td> | ||
<td>指定当前选中的项目 value</td> | ||
<td>Array</td> | ||
<td>[]</td> | ||
</tr> | ||
</tbody> | ||
</table> | ||
<Anchor title="CheckboxGroup events" h3></Anchor> | ||
<table> | ||
<thead> | ||
<tr> | ||
<th>事件名</th> | ||
<th>说明</th> | ||
<th>返回值</th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
<tr> | ||
<td>bind:change</td> | ||
<td>切换选项时触发</td> | ||
<td>current</td> | ||
</tr> | ||
</tbody> | ||
</table> | ||
<Anchor title="CheckboxGroup properties" h3></Anchor> | ||
<table> | ||
<thead> | ||
<tr> | ||
<th>属性</th> | ||
<th>说明</th> | ||
<th>类型</th> | ||
<th>默认值</th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
<tr> | ||
<td>i-class</td> | ||
<td>自定义 class 类名</td> | ||
<td>String</td> | ||
<td>-</td> | ||
</tr> | ||
<tr> | ||
<td>value</td> | ||
<td>当前项的 value</td> | ||
<td>String</td> | ||
<td>-</td> | ||
</tr> | ||
<tr> | ||
<td>checked</td> | ||
<td>当前项是否选中</td> | ||
<td>Boolean</td> | ||
<td>false</td> | ||
</tr> | ||
<tr> | ||
<td>disabled</td> | ||
<td>是否禁用当前项</td> | ||
<td>Boolean</td> | ||
<td>false</td> | ||
</tr> | ||
<tr> | ||
<td>color</td> | ||
<td>主题色</td> | ||
<td>String</td> | ||
<td>-</td> | ||
</tr> | ||
<tr> | ||
<td>position</td> | ||
<td>位置,可选值为 left 或 right</td> | ||
<td>String</td> | ||
<td>left</td> | ||
</tr> | ||
</tbody> | ||
</table> | ||
<Anchor title="CheckboxGroup events" h3></Anchor> | ||
<table> | ||
<thead> | ||
<tr> | ||
<th>事件名</th> | ||
<th>说明</th> | ||
<th>返回值</th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
<tr> | ||
<td>bind:change</td> | ||
<td>切换选项时触发</td> | ||
<td>current</td> | ||
</tr> | ||
</tbody> | ||
</table> | ||
</div> | ||
</article> | ||
</i-article> | ||
</template> | ||
<script> | ||
import iArticle from '../../components/article.vue'; | ||
import iCode from 'iCode'; | ||
import Demo from '../../components/demo.vue'; | ||
import Code from '../../code/checkbox'; | ||
import Anchor from '../../components/anchor.vue'; | ||
export default { | ||
components: { | ||
iArticle, | ||
iCode, | ||
Demo, | ||
Anchor | ||
}, | ||
data () { | ||
return { | ||
code: Code | ||
} | ||
} | ||
} | ||
</script> |