mirror of
https://gitee.com/vant-contrib/vant.git
synced 2025-04-06 03:57:59 +08:00
Merge branch 'master' of gitlab.qima-inc.com:fe/zanui-vue
This commit is contained in:
commit
22747de5f9
@ -16,6 +16,25 @@
|
|||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
export default {
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
switchState: true
|
||||||
|
};
|
||||||
|
},
|
||||||
|
computed: {
|
||||||
|
switchStateText() {
|
||||||
|
return this.switchState ? ' ON' : 'OFF';
|
||||||
|
}
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
updateState(newState) {
|
||||||
|
this.switchState = newState;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
|
||||||
## Switch组件
|
## Switch组件
|
||||||
|
|
||||||
@ -24,7 +43,7 @@
|
|||||||
:::demo 基础用法
|
:::demo 基础用法
|
||||||
```html
|
```html
|
||||||
<div class="demo-switch__wrapper">
|
<div class="demo-switch__wrapper">
|
||||||
<zan-switch class="some-customized-class" :checked="switchState" :on-change="updateState"></zan-switch>
|
<zan-switch class="some-customized-class" :checked="switchState" @change="updateState"></zan-switch>
|
||||||
<div class="demo-switch__text">{{switchStateText}}</div>
|
<div class="demo-switch__text">{{switchStateText}}</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="demo-switch__wrapper">
|
<div class="demo-switch__wrapper">
|
||||||
@ -73,4 +92,3 @@ export default {
|
|||||||
| checked | 开关状态 | boolean | false | true, false |
|
| checked | 开关状态 | boolean | false | true, false |
|
||||||
| loading | loading状态 | boolean | false | true, false |
|
| loading | loading状态 | boolean | false | true, false |
|
||||||
| disabled | 禁用状态 | boolean | false | true, false |
|
| disabled | 禁用状态 | boolean | false | true, false |
|
||||||
| onChange | 回调 | function | function(){} | - |
|
|
||||||
|
@ -16,11 +16,30 @@ export default {
|
|||||||
showSimpleToast() {
|
showSimpleToast() {
|
||||||
Toast('我是提示文案,建议不超过十五字~');
|
Toast('我是提示文案,建议不超过十五字~');
|
||||||
},
|
},
|
||||||
showToast(type) {
|
showLoadingToast() {
|
||||||
Toast({
|
Toast.loading();
|
||||||
type: type,
|
},
|
||||||
message: '文案信息'
|
showSuccessToast() {
|
||||||
})
|
Toast.success('成功文案');
|
||||||
|
},
|
||||||
|
showFailToast() {
|
||||||
|
Toast.fail('失败文案');
|
||||||
|
},
|
||||||
|
showCustomizedToast(duration) {
|
||||||
|
let leftSec = duration / 1000;
|
||||||
|
let toast = Toast({
|
||||||
|
duration: duration + 1000,
|
||||||
|
type: 'success',
|
||||||
|
message: leftSec.toString()
|
||||||
|
});
|
||||||
|
window.setInterval(() => {
|
||||||
|
if (leftSec <= 1) {
|
||||||
|
window.clearInterval();
|
||||||
|
toast.message = '跳转中...'
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
toast.message = (--leftSec).toString();
|
||||||
|
}, 1000);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -32,11 +51,11 @@ export default {
|
|||||||
|
|
||||||
:::demo 基础用法
|
:::demo 基础用法
|
||||||
```html
|
```html
|
||||||
<zan-button @click="showSimpleToast()">普通文字提示</zan-button>
|
<zan-button @click="showSimpleToast">普通文字提示</zan-button>
|
||||||
|
<zan-button @click="showLoadingToast">加载Toast</zan-button>
|
||||||
<zan-button @click="showToast('loading')">加载Toast</zan-button>
|
<zan-button @click="showSuccessToast">成功</zan-button>
|
||||||
<zan-button @click="showToast('success')">成功</zan-button>
|
<zan-button @click="showFailToast">失败</zan-button>
|
||||||
<zan-button @click="showToast('failure')">失败</zan-button>
|
<zan-button @click="showCustomizedToast(5000)">倒数5秒</zan-button>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import { Toast } from 'src/index';
|
import { Toast } from 'src/index';
|
||||||
@ -46,11 +65,30 @@ export default {
|
|||||||
showSimpleToast() {
|
showSimpleToast() {
|
||||||
Toast('我是提示文案,建议不超过十五字~');
|
Toast('我是提示文案,建议不超过十五字~');
|
||||||
},
|
},
|
||||||
showToast(type) {
|
showLoadingToast() {
|
||||||
Toast({
|
Toast.loading();
|
||||||
type: type,
|
},
|
||||||
message: '文案信息'
|
showSuccessToast() {
|
||||||
})
|
Toast.success('成功文案');
|
||||||
|
},
|
||||||
|
showFailToast() {
|
||||||
|
Toast.fail('失败文案');
|
||||||
|
},
|
||||||
|
showCustomizedToast(duration) {
|
||||||
|
let leftSec = duration / 1000;
|
||||||
|
let toast = Toast({
|
||||||
|
duration: duration + 1000,
|
||||||
|
type: 'success',
|
||||||
|
message: leftSec.toString()
|
||||||
|
});
|
||||||
|
window.setInterval(() => {
|
||||||
|
if (leftSec <= 1) {
|
||||||
|
window.clearInterval();
|
||||||
|
toast.message = '跳转中...'
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
toast.message = (--leftSec).toString();
|
||||||
|
}, 1000);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -58,7 +96,6 @@ export default {
|
|||||||
```
|
```
|
||||||
:::
|
:::
|
||||||
|
|
||||||
|
|
||||||
### API
|
### API
|
||||||
|
|
||||||
| 参数 | 说明 | 类型 | 默认值 | 可选值 |
|
| 参数 | 说明 | 类型 | 默认值 | 可选值 |
|
||||||
|
@ -15,7 +15,6 @@
|
|||||||
* @param {boolean} [checked=false] - 开关状态
|
* @param {boolean} [checked=false] - 开关状态
|
||||||
* @param {boolean} [disabled=false] - 禁用
|
* @param {boolean} [disabled=false] - 禁用
|
||||||
* @param {boolean} [loading=false] - loading状态
|
* @param {boolean} [loading=false] - loading状态
|
||||||
* @param {callback} [onChange] - 开关状态改变回调函数。
|
|
||||||
*
|
*
|
||||||
* @example
|
* @example
|
||||||
* <zan-switch checked="true" disabled="false"></zan-switch>
|
* <zan-switch checked="true" disabled="false"></zan-switch>
|
||||||
@ -34,10 +33,6 @@ export default {
|
|||||||
loading: {
|
loading: {
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
default: false
|
default: false
|
||||||
},
|
|
||||||
onChange: {
|
|
||||||
type: Function,
|
|
||||||
default: function() {}
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
@ -54,7 +49,7 @@ export default {
|
|||||||
*/
|
*/
|
||||||
toggleState: function() {
|
toggleState: function() {
|
||||||
if (this.disabled || this.loading) return;
|
if (this.disabled || this.loading) return;
|
||||||
this.onChange(!this.checked);
|
this.$emit('change', !this.checked);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
import Vue from 'vue';
|
import Vue from 'vue';
|
||||||
|
import merge from 'src/utils/merge';
|
||||||
|
|
||||||
const ToastConstructor = Vue.extend(require('./toast.vue'));
|
const ToastConstructor = Vue.extend(require('./toast.vue'));
|
||||||
let toastQueue = [];
|
let toastQueue = [];
|
||||||
@ -50,4 +51,26 @@ var Toast = (options = {}) => {
|
|||||||
return instance;
|
return instance;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Toast.loading = (options) => {
|
||||||
|
return new Toast(merge({
|
||||||
|
type: 'loading'
|
||||||
|
}, options));
|
||||||
|
};
|
||||||
|
|
||||||
|
Toast.success = (options) => {
|
||||||
|
const message = typeof options === 'string' ? options : options.message;
|
||||||
|
return new Toast(merge({
|
||||||
|
type: 'success',
|
||||||
|
message: message
|
||||||
|
}, options));
|
||||||
|
};
|
||||||
|
|
||||||
|
Toast.fail = (options) => {
|
||||||
|
const message = typeof options === 'string' ? options : options.message;
|
||||||
|
return new Toast(merge({
|
||||||
|
type: 'fail',
|
||||||
|
message: message
|
||||||
|
}, options));
|
||||||
|
};
|
||||||
|
|
||||||
export default Toast;
|
export default Toast;
|
||||||
|
@ -22,7 +22,7 @@
|
|||||||
import zanLoading from 'packages/loading';
|
import zanLoading from 'packages/loading';
|
||||||
import zanIcon from 'packages/icon';
|
import zanIcon from 'packages/icon';
|
||||||
|
|
||||||
const TOAST_TYPES = ['text', 'loading', 'success', 'failure'];
|
const TOAST_TYPES = ['text', 'loading', 'success', 'fail'];
|
||||||
/**
|
/**
|
||||||
* zan-toast
|
* zan-toast
|
||||||
* @module components/toast
|
* @module components/toast
|
||||||
@ -50,7 +50,7 @@ export default {
|
|||||||
type: String,
|
type: String,
|
||||||
default: '',
|
default: '',
|
||||||
validate(value) {
|
validate(value) {
|
||||||
if (this.type === 'success' || this.type === 'failure') {
|
if (this.type === 'success' || this.type === 'fail') {
|
||||||
return value.length <= 16;
|
return value.length <= 16;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -19,7 +19,8 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
@m text {
|
@m text {
|
||||||
padding: 11px;
|
padding: 12px;
|
||||||
|
min-width: 200px;
|
||||||
}
|
}
|
||||||
|
|
||||||
@m default {
|
@m default {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user