-
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
230 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,73 @@ | ||
let code = {}; | ||
|
||
code.import = ` | ||
"usingComponents": { | ||
"i-radio-group": "../../dist/radio-group/index", | ||
"i-radio": "../../dist/radio/index" | ||
} | ||
`; | ||
code.usage = ` | ||
<i-panel title="group-水果"> | ||
<i-radio-group current="{{current}}" bindchange="handleFruitChange"> | ||
<i-radio wx:for="{{fruit}}" position="{{position}}" wx:key="{{item.id}}" value="{{item.name}}"> | ||
</i-radio> | ||
</i-radio-group> | ||
</i-panel> | ||
<i-button bindclick="handleClick" type="ghost">切换单选框位置</i-button> | ||
<i-panel title="radio-动物"> | ||
<i-radio value="{{animal}}" disabled="{{disabled}}" checked="{{checked}}" bindchange="handleAnimalChange"> | ||
</i-radio> | ||
</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 = {} }) { | ||
this.setData({ | ||
current: detail.value | ||
}); | ||
}, | ||
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>Radio 单选</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="RadioGroup 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>String</td> | ||
<td>-</td> | ||
</tr> | ||
</tbody> | ||
</table> | ||
<Anchor title="RadioGroup 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="Radio 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="Radio 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/radio'; | ||
import Anchor from '../../components/anchor.vue'; | ||
export default { | ||
components: { | ||
iArticle, | ||
iCode, | ||
Demo, | ||
Anchor | ||
}, | ||
data () { | ||
return { | ||
code: Code | ||
} | ||
} | ||
} | ||
</script> |