[new feature] Button: add url、to、replace prop (#2754)

This commit is contained in:
neverland 2019-02-15 19:28:20 +08:00 committed by GitHub
parent c5bd04e30a
commit 632cfbcf36
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 9 additions and 1 deletions

View File

@ -71,6 +71,9 @@ Vue.use(Button);
| disabled | Whether to disable button | `Boolean` | `false` |
| loading | Whether show loading status | `Boolean` | `false` |
| loading-text | Loading text | `String` | - |
| url | Link URL | `String` | - |
| to | Target route of the link, same as to of `vue-router` | `String | Object` | - |
| replace | If true, the navigation will not leave a history record | `String` | `false` |
### Event

View File

@ -1,5 +1,6 @@
import { use } from '../utils';
import { emit, inherit } from '../utils/functional';
import { routeProps, functionalRoute } from '../mixins/router';
import Loading from '../loading';
const [sfc, bem] = use('button');
@ -10,6 +11,7 @@ function Button(h, props, slots, ctx) {
const onClick = event => {
if (!loading && !disabled) {
emit(ctx, 'click', event);
functionalRoute(ctx);
}
};
@ -48,6 +50,7 @@ function Button(h, props, slots, ctx) {
}
Button.props = {
...routeProps,
text: String,
block: Boolean,
plain: Boolean,

View File

@ -61,7 +61,6 @@ Vue.use(Button);
<van-button size="mini">迷你按钮</van-button>
```
### API
| 参数 | 说明 | 类型 | 默认值 | 版本 |
@ -78,6 +77,9 @@ Vue.use(Button);
| disabled | 是否禁用按钮 | `Boolean` | `false` | - |
| loading | 是否显示为加载状态 | `Boolean` | `false` | - |
| loading-text | 加载状态提示文字 | `String` | - | 1.6.3 |
| url | 跳转链接 | `String` | - | 1.6.5 |
| to | 路由跳转对象,同 `vue-router` 的 to | `String | Object` | - | 1.6.5 |
| replace | 跳转时是否替换当前页面历史 | `String` | `false` | 1.6.5 |
### Event