ソースを参照

Merge branch 'next' of https://github.com/jdf2e/nutui into next

suzigang 3 年 前
コミット
88a2eb647e

+ 15 - 0
src/packages/__VUE/menu/index.taro.vue

@@ -81,10 +81,25 @@ export default create({
           }
           }
         };
         };
 
 
+        const removeLink = (child: any) => {
+          if (child.proxy) {
+            let internalIndex = internalChildren.indexOf(child);
+            if (internalIndex > -1) {
+              internalChildren.splice(internalIndex, 1);
+            }
+
+            let publicIndex = publicChildren.indexOf(child.proxy);
+            if (internalIndex > -1) {
+              publicChildren.splice(publicIndex, 1);
+            }
+          }
+        };
+
         provide(
         provide(
           'menuParent',
           'menuParent',
           Object.assign(
           Object.assign(
             {
             {
+              removeLink,
               link,
               link,
               children: publicChildren,
               children: publicChildren,
               internalChildren
               internalChildren

+ 15 - 0
src/packages/__VUE/menu/index.vue

@@ -79,10 +79,25 @@ export default create({
           }
           }
         };
         };
 
 
+        const removeLink = (child: any) => {
+          if (child.proxy) {
+            let internalIndex = internalChildren.indexOf(child);
+            if (internalIndex > -1) {
+              internalChildren.splice(internalIndex, 1);
+            }
+
+            let publicIndex = publicChildren.indexOf(child.proxy);
+            if (internalIndex > -1) {
+              publicChildren.splice(publicIndex, 1);
+            }
+          }
+        };
+
         provide(
         provide(
           'menuParent',
           'menuParent',
           Object.assign(
           Object.assign(
             {
             {
+              removeLink,
               link,
               link,
               children: publicChildren,
               children: publicChildren,
               internalChildren
               internalChildren

+ 1 - 15
src/packages/__VUE/menuitem/index.scss

@@ -36,24 +36,10 @@
   }
   }
 }
 }
 
 
-.menu-item__pop-container {
-  position: fixed;
-  top: 0;
-  bottom: 0;
-  right: 0;
-  left: 0;
-  overflow: hidden;
-}
-
 .nut-menu__pop {
 .nut-menu__pop {
   transition: all 0 ease 0;
   transition: all 0 ease 0;
   transform: none;
   transform: none;
-  position: absolute !important;
-}
-
-.nut-menu__overlay {
-  position: absolute !important;
-  top: auto;
+  overflow: hidden;
 }
 }
 
 
 .placeholder-element {
 .placeholder-element {

+ 11 - 5
src/packages/__VUE/menuitem/index.taro.vue

@@ -9,8 +9,10 @@
     >
     >
     </div>
     </div>
     <nut-popup
     <nut-popup
-      class="menu-item__pop-container"
-      :containerStyle="
+      :style="
+        parent.props.direction === 'down' ? { top: parent.offset.value + 'px' } : { bottom: parent.offset.value + 'px' }
+      "
+      :overlay-style="
         parent.props.direction === 'down' ? { top: parent.offset.value + 'px' } : { bottom: parent.offset.value + 'px' }
         parent.props.direction === 'down' ? { top: parent.offset.value + 'px' } : { bottom: parent.offset.value + 'px' }
       "
       "
       v-bind="$attrs"
       v-bind="$attrs"
@@ -18,7 +20,6 @@
       :position="parent.props.direction === 'down' ? 'top' : 'bottom'"
       :position="parent.props.direction === 'down' ? 'top' : 'bottom'"
       :duration="parent.props.duration"
       :duration="parent.props.duration"
       pop-class="nut-menu__pop"
       pop-class="nut-menu__pop"
-      overlayClass="nut-menu__overlay"
       :overlay="parent.props.overlay"
       :overlay="parent.props.overlay"
       :lockScroll="parent.props.lockScroll"
       :lockScroll="parent.props.lockScroll"
       @closed="handleClose"
       @closed="handleClose"
@@ -60,7 +61,7 @@
   </view>
   </view>
 </template>
 </template>
 <script lang="ts">
 <script lang="ts">
-import { reactive, PropType, inject, getCurrentInstance, computed } from 'vue';
+import { reactive, PropType, inject, getCurrentInstance, computed, onUnmounted } from 'vue';
 import { createComponent } from '@/packages/utils/create';
 import { createComponent } from '@/packages/utils/create';
 const { componentName, create } = createComponent('menu-item');
 const { componentName, create } = createComponent('menu-item');
 import Icon from '../icon/index.taro.vue';
 import Icon from '../icon/index.taro.vue';
@@ -113,11 +114,16 @@ export default create({
         // 获取子组件自己的实例
         // 获取子组件自己的实例
         const instance = getCurrentInstance()!;
         const instance = getCurrentInstance()!;
 
 
-        const { link } = parent;
+        const { link, removeLink } = parent;
 
 
         // @ts-ignore
         // @ts-ignore
         link(instance);
         link(instance);
 
 
+        onUnmounted(() => {
+          // @ts-ignore
+          removeLink(instance);
+        });
+
         return {
         return {
           parent
           parent
         };
         };

+ 7 - 2
src/packages/__VUE/menuitem/index.vue

@@ -55,7 +55,7 @@
   </view>
   </view>
 </template>
 </template>
 <script lang="ts">
 <script lang="ts">
-import { reactive, PropType, inject, getCurrentInstance, computed } from 'vue';
+import { reactive, PropType, inject, getCurrentInstance, computed, onUnmounted } from 'vue';
 import { createComponent } from '@/packages/utils/create';
 import { createComponent } from '@/packages/utils/create';
 const { componentName, create } = createComponent('menu-item');
 const { componentName, create } = createComponent('menu-item');
 import Icon from '../icon/index.vue';
 import Icon from '../icon/index.vue';
@@ -104,11 +104,16 @@ export default create({
         // 获取子组件自己的实例
         // 获取子组件自己的实例
         const instance = getCurrentInstance()!;
         const instance = getCurrentInstance()!;
 
 
-        const { link } = parent;
+        const { link, removeLink } = parent;
 
 
         // @ts-ignore
         // @ts-ignore
         link(instance);
         link(instance);
 
 
+        onUnmounted(() => {
+          // @ts-ignore
+          removeLink(instance);
+        });
+
         return {
         return {
           parent
           parent
         };
         };