mirror of
https://gitee.com/vant-contrib/vant.git
synced 2025-08-07 04:59:46 +08:00
[new feature] Button: add url、to、replace prop (#2754)
This commit is contained in:
parent
c5bd04e30a
commit
632cfbcf36
@ -71,6 +71,9 @@ Vue.use(Button);
|
|||||||
| disabled | Whether to disable button | `Boolean` | `false` |
|
| disabled | Whether to disable button | `Boolean` | `false` |
|
||||||
| loading | Whether show loading status | `Boolean` | `false` |
|
| loading | Whether show loading status | `Boolean` | `false` |
|
||||||
| loading-text | Loading text | `String` | - |
|
| 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
|
### Event
|
||||||
|
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
import { use } from '../utils';
|
import { use } from '../utils';
|
||||||
import { emit, inherit } from '../utils/functional';
|
import { emit, inherit } from '../utils/functional';
|
||||||
|
import { routeProps, functionalRoute } from '../mixins/router';
|
||||||
import Loading from '../loading';
|
import Loading from '../loading';
|
||||||
|
|
||||||
const [sfc, bem] = use('button');
|
const [sfc, bem] = use('button');
|
||||||
@ -10,6 +11,7 @@ function Button(h, props, slots, ctx) {
|
|||||||
const onClick = event => {
|
const onClick = event => {
|
||||||
if (!loading && !disabled) {
|
if (!loading && !disabled) {
|
||||||
emit(ctx, 'click', event);
|
emit(ctx, 'click', event);
|
||||||
|
functionalRoute(ctx);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -48,6 +50,7 @@ function Button(h, props, slots, ctx) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Button.props = {
|
Button.props = {
|
||||||
|
...routeProps,
|
||||||
text: String,
|
text: String,
|
||||||
block: Boolean,
|
block: Boolean,
|
||||||
plain: Boolean,
|
plain: Boolean,
|
||||||
|
@ -61,7 +61,6 @@ Vue.use(Button);
|
|||||||
<van-button size="mini">迷你按钮</van-button>
|
<van-button size="mini">迷你按钮</van-button>
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
### API
|
### API
|
||||||
|
|
||||||
| 参数 | 说明 | 类型 | 默认值 | 版本 |
|
| 参数 | 说明 | 类型 | 默认值 | 版本 |
|
||||||
@ -78,6 +77,9 @@ Vue.use(Button);
|
|||||||
| disabled | 是否禁用按钮 | `Boolean` | `false` | - |
|
| disabled | 是否禁用按钮 | `Boolean` | `false` | - |
|
||||||
| loading | 是否显示为加载状态 | `Boolean` | `false` | - |
|
| loading | 是否显示为加载状态 | `Boolean` | `false` | - |
|
||||||
| loading-text | 加载状态提示文字 | `String` | - | 1.6.3 |
|
| 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
|
### Event
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user