提交 d7deea00 编写于 作者: richard_1015's avatar richard_1015

fix: demo getCurrentInstance build error

上级 304204ee
......@@ -52,7 +52,7 @@ const { createDemo } = createComponent('inputnumber');
export default createDemo({
props: {},
setup() {
let { ctx } = getCurrentInstance();
let { proxy } = getCurrentInstance();
const state = reactive({
val1: 1,
......@@ -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 {
......
......@@ -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,
......@@ -52,7 +52,7 @@ export default createDemo({
val8: 3
});
const onChange = val => {
ctx.$toast.text(state.result);
proxy.$toast.text(state.result);
};
return {
state,
......
......@@ -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,
......@@ -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('点击取消按钮关闭弹窗');
}
};
......
......@@ -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,
......@@ -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 {
......
......@@ -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);
......
......@@ -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,
......@@ -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);
......
......@@ -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: 100000 });
proxy.$toast.text(msg, { duration: 100000 });
};
const successToast = msg => {
ctx.$toast.success(msg, { duration: 100000 });
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 {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册