wangyue217 5 年 前
コミット
2d27d7b145
2 ファイル変更20 行追加13 行削除
  1. 14 8
      src/packages/notify/demo.vue
  2. 6 5
      src/packages/notify/index.ts

+ 14 - 8
src/packages/notify/demo.vue

@@ -1,7 +1,7 @@
 <template>
   <div class="demo">
     <h2>基础用法</h2>
-    <nut-cell :showIcon="true" :isLink="true" @click="notify1('通知内容')">
+    <nut-cell :showIcon="true" :isLink="true" @click="notify1('isVisible1')">
       <span>
         <label>基础用法</label>
       </span>
@@ -10,17 +10,23 @@
 </template>
 
 <script lang="ts">
-import { createApp } from 'vue';
+import { reactive, createApp } from 'vue';
 import { createComponent } from '@/utils/create';
-import notify from './index';
+// import notify from './index';
 const { createDemo } = createComponent('notify');
-const app = createApp({});
-app.use(notify);
+// const app = createApp({});
+// app.use(notify);
 export default createDemo({
-  props: {},
   setup() {
-    const notify1 = () => {
-      notify('content');
+    const state = reactive({
+      isVisible1: false,
+      isVisible2: false,
+      isVisible3: false,
+      isVisible4: false,
+      isVisible5: false
+    });
+    const notify1 = param => {
+      state[`${param}`] = !state[`${param}`];
     };
     return {
       notify1

+ 6 - 5
src/packages/notify/index.ts

@@ -1,4 +1,4 @@
-import VanNotify from './index.vue';
+import NutNotify from './index.vue';
 import {
   createApp,
   reactive,
@@ -74,12 +74,13 @@ function initInstance() {
   ({ instance } = mountComponent({
     setup() {
       const { state, toggle } = usePopupState();
-      return h('img', {});
+      return h(NutNotify, { ...state, 'onUpdate:show': toggle });
     }
   }));
 }
-
+// 入口
 function Notify(options) {
+  debugger;
   if (!inBrowser) {
     return;
   }
@@ -134,10 +135,10 @@ Notify.resetDefaultOptions = () => {
 };
 
 Notify.install = app => {
-  app.use(VanNotify);
+  app.use(NutNotify);
   app.config.globalProperties.$notify = Notify;
 };
 
-Notify.Component = VanNotify;
+Notify.Component = NutNotify;
 
 export default Notify;