Skip to content

Commit

Permalink
upd: toast
Browse files Browse the repository at this point in the history
  • Loading branch information
szg2008 committed Mar 30, 2021
2 parents 0a915f8 + d7deea0 commit dc1e97a
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 30 deletions.
8 changes: 4 additions & 4 deletions src/packages/inputnumber/demo.vue
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ const { createDemo } = createComponent('inputnumber');
export default createDemo({
props: {},
setup() {
let { ctx } = getCurrentInstance();
let { proxy } = getCurrentInstance();
const state = reactive({
val1: 1,
Expand All @@ -67,15 +67,15 @@ export default createDemo({
});
const onChange = (value: number) => {
ctx.$toast.loading('异步演示 2 秒后更改');
proxy.$toast.loading('异步演示 2 秒后更改');
setTimeout(() => {
state.val8 = value;
ctx.$toast.hide();
proxy.$toast.hide();
}, 2000);
};
const overlimit = () => {
ctx.$toast.warn('超出限制事件触发');
proxy.$toast.warn('超出限制事件触发');
};
return {
Expand Down
4 changes: 2 additions & 2 deletions src/packages/rate/demo.vue
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ import { createComponent } from '@/utils/create';
const { createDemo } = createComponent('rate');
export default createDemo({
setup() {
let { ctx } = getCurrentInstance();
let { proxy } = getCurrentInstance();
const state = reactive({
val: 3,
Expand All @@ -52,7 +52,7 @@ export default createDemo({
val8: 3
});
const onChange = val => {
ctx.$toast.text(state.result);
proxy.$toast.text(state.result);
};
return {
state,
Expand Down
12 changes: 6 additions & 6 deletions src/packages/shortpassword/demo.vue
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ import { createComponent } from '@/utils/create';
const { createDemo } = createComponent('shortpassword');
export default createDemo({
setup() {
let { ctx } = getCurrentInstance() as any;
let { proxy } = getCurrentInstance() as any;
const state = reactive({
visible: false,
Expand All @@ -84,21 +84,21 @@ export default createDemo({
});
const methods = {
onChange(val: string) {
val && ctx.$toast.text(val);
val && proxy.$toast.text(val);
},
onOk(val: string) {
val && ctx.$toast.text(val);
val && proxy.$toast.text(val);
state.visible = false;
},
onComplete() {},
onTips() {
ctx.$toast.text('执行忘记密码逻辑');
proxy.$toast.text('执行忘记密码逻辑');
},
close() {
ctx.$toast.text('点击icon关闭弹窗');
proxy.$toast.text('点击icon关闭弹窗');
},
cancel() {
ctx.$toast.text('点击取消按钮关闭弹窗');
proxy.$toast.text('点击取消按钮关闭弹窗');
}
};
Expand Down
8 changes: 4 additions & 4 deletions src/packages/shortpassword/doc.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ app.use(ShortPassword);
``` javascript
import { reactive, getCurrentInstance } from 'vue';
setup() {
let { ctx } = getCurrentInstance();
let { proxy } = getCurrentInstance();
const state = reactive({
visible: false,
noButton: true,
Expand All @@ -45,17 +45,17 @@ setup() {
});
const methods = {
onChange(val: string) {
val && ctx.$toast.text(val);
val && proxy.$toast.text(val);
},
onOk(val: string) {
val && ctx.$toast.text(val);
val && proxy.$toast.text(val);
state.visible = false;
},
onComplete() {

},
onTips() {
ctx.$toast.text('执行忘记密码逻辑');
proxy.$toast.text('执行忘记密码逻辑');
}
};
return {
Expand Down
6 changes: 3 additions & 3 deletions src/packages/switch/demo.vue
Original file line number Diff line number Diff line change
Expand Up @@ -47,15 +47,15 @@ import { createComponent } from '@/utils/create';
const { createDemo } = createComponent('switch');
export default createDemo({
setup() {
let { ctx } = getCurrentInstance() as any;
let { proxy } = getCurrentInstance() as any;
const checked = ref(true);
const checkedAsync = ref(true);
const change = (value: boolean, event: Event) => {
ctx.$toast.text(`触发了change事件,开关状态:${value}`);
proxy.$toast.text(`触发了change事件,开关状态:${value}`);
};
const changeAsync = (value: boolean, event: Event) => {
ctx.$toast.text(`2秒后异步触发 ${value}`);
proxy.$toast.text(`2秒后异步触发 ${value}`);
setTimeout(() => {
checkedAsync.value = value;
}, 2000);
Expand Down
8 changes: 4 additions & 4 deletions src/packages/switch/doc.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,10 @@ export default {
import { ref, getCurrentInstance } from 'vue';
export default {
setup() {
let { ctx } = getCurrentInstance() as any;
let { proxy } = getCurrentInstance() as any;
const checked = ref(true);
const change = (value: boolean, event: Event) => {
ctx.$toast.text(`触发了change事件,开关状态:${value}`);
proxy.$toast.text(`触发了change事件,开关状态:${value}`);
};
return {
checked,
Expand All @@ -68,10 +68,10 @@ export default {
import { ref, getCurrentInstance } from 'vue';
export default {
setup() {
let { ctx } = getCurrentInstance() as any;
let { proxy } = getCurrentInstance() as any;
const checkedAsync = ref(true);
const changeAsync = (value: boolean, event: Event) => {
ctx.$toast.text(`2秒后异步触发 ${value}`);
proxy.$toast.text(`2秒后异步触发 ${value}`);
setTimeout(() => {
checkedAsync.value = value;
}, 2000);
Expand Down
14 changes: 7 additions & 7 deletions src/packages/toast/demo.vue
Original file line number Diff line number Diff line change
Expand Up @@ -39,24 +39,24 @@ const { createDemo } = createComponent('toast');
export default createDemo({
setup() {
const { ctx } = getCurrentInstance();
const { proxy } = getCurrentInstance();
const textToast = msg => {
ctx.$toast.text(msg, { duration: 1000 });
proxy.$toast.text(msg, { duration: 100000 });
};
const successToast = msg => {
ctx.$toast.success(msg, { duration: 2000 });
proxy.$toast.success(msg, { duration: 100000 });
};
const errorToast = msg => {
ctx.$toast.fail(msg);
proxy.$toast.fail(msg);
};
const warningToast = msg => {
ctx.$toast.warn(msg);
proxy.$toast.warn(msg);
};
const loadingToast = msg => {
ctx.$toast.loading(msg, { duration: 0, id: 'test' });
proxy.$toast.loading(msg, { duration: 0, id: 'test' });
setTimeout(() => {
ctx.$toast.success('加载完成', { id: 'test', duration: 2000 });
proxy.$toast.success('加载完成', { id: 'test', duration: 2000 });
}, 2000);
};
return {
Expand Down

0 comments on commit dc1e97a

Please sign in to comment.