Browse Source

upd: toast

suzigang 4 years ago
parent
commit
dc1e97abc3

+ 4 - 4
src/packages/inputnumber/demo.vue

@@ -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 {

+ 2 - 2
src/packages/rate/demo.vue

@@ -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,

+ 6 - 6
src/packages/shortpassword/demo.vue

@@ -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('点击取消按钮关闭弹窗');
       }
     };
 

+ 4 - 4
src/packages/shortpassword/doc.md

@@ -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 {

+ 3 - 3
src/packages/switch/demo.vue

@@ -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);

+ 4 - 4
src/packages/switch/doc.md

@@ -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);

+ 7 - 7
src/packages/toast/demo.vue

@@ -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 {