Skip to content

Commit

Permalink
add InputNumber
Browse files Browse the repository at this point in the history
  • Loading branch information
icarusion committed Jun 4, 2018
1 parent b2bfb09 commit 47c8ecf
Show file tree
Hide file tree
Showing 3 changed files with 152 additions and 0 deletions.
43 changes: 43 additions & 0 deletions src/code/input-number.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
let code = {};

code.import = `
"usingComponents": {
"i-input-number": "../../dist/input-number/index"
}
`;
code.usage = `
<i-panel title="基础用法">
<view style="padding: 16px">
<i-input-number value="{{ value1 }}" min="0" max="100" bindchange="handleChange1" />
</view>
</i-panel>
<i-panel title="小数">
<view style="padding: 16px">
<i-input-number value="{{ value2 }}" min="0" max="100" step="0.2" bindchange="handleChange2" />
</view>
</i-panel>
`;

code.js = `
Page({
data: {
value1: 1,
value2: 0.1
},
handleChange1 ({ detail }) {
this.setData({
value1: detail.value
})
},
handleChange2 ({ detail }) {
this.setData({
value2: detail.value
})
}
});
`;

export default code;
7 changes: 7 additions & 0 deletions src/router.js
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,13 @@ const routers = [
},
component: (resolve) => require(['./views/components/rate.vue'], resolve)
},
{
path: '/components/input-number',
meta: {
title: '数字输入框 InputNumber'
},
component: (resolve) => require(['./views/components/input-number.vue'], resolve)
},
{
path: '*',
redirect: '/'
Expand Down
102 changes: 102 additions & 0 deletions src/views/components/input-number.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
<template>
<i-article>
<article>
<h1>InputNumber 数字输入框</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="InputNumber 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>当前值</td>
<td>Number</td>
<td>1</td>
</tr>
<tr>
<td>max</td>
<td>最大值</td>
<td>Number</td>
<td>Infinity</td>
</tr>
<tr>
<td>min</td>
<td>最小值</td>
<td>Number</td>
<td>-Infinity</td>
</tr>
<tr>
<td>step</td>
<td>每次改变的步伐,可以是小数</td>
<td>Number</td>
<td>1</td>
</tr>
</tbody>
</table>
<Anchor title="InputNumber events" h3></Anchor>
<table>
<thead>
<tr>
<th>事件名</th>
<th>说明</th>
<th>返回值</th>
</tr>
</thead>
<tbody>
<tr>
<td>bind:change</td>
<td>当绑定值变化时触发的事件</td>
<td>{ value, type }</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/input-number';
import Anchor from '../../components/anchor.vue';
export default {
components: {
iArticle,
iCode,
Demo,
Anchor
},
data () {
return {
code: Code
}
}
}
</script>

0 comments on commit 47c8ecf

Please sign in to comment.