瀏覽代碼

vant组件中的下拉菜单添加一个slot

zhaoxiaohai 3 年之前
父節點
當前提交
79b19ba47b
共有 1 個文件被更改,包括 10 次插入17 次删除
  1. 10 17
      miniprogram_npm/@vant/weapp/dropdown-menu/index.wxml

+ 10 - 17
miniprogram_npm/@vant/weapp/dropdown-menu/index.wxml

@@ -2,22 +2,15 @@
 <wxs src="./index.wxs" module="computed" />
 
 <view class="van-dropdown-menu van-dropdown-menu--top-bottom custom-class">
-  <view
-    wx:for="{{ itemListData }}"
-    wx:key="index"
-    data-index="{{ index }}"
-    class="{{ utils.bem('dropdown-menu__item', { disabled: item.disabled }) }}"
-    bind:tap="onTitleTap"
-  >
-    <view
-      class="{{ item.titleClass }} {{ utils.bem('dropdown-menu__title', { active: item.showPopup, down: item.showPopup === (direction === 'down') }) }}"
-      style="{{ item.showPopup ? 'color:' + activeColor : '' }}"
-    >
-      <view class="van-ellipsis">
-        {{ computed.displayTitle(item) }}
-      </view>
+    <slot name='leftSlot' />
+
+    <view wx:for="{{ itemListData }}" wx:key="index" data-index="{{ index }}" class="{{ utils.bem('dropdown-menu__item', { disabled: item.disabled }) }}" bind:tap="onTitleTap">
+        <view class="{{ item.titleClass }} {{ utils.bem('dropdown-menu__title', { active: item.showPopup, down: item.showPopup === (direction === 'down') }) }}" style="{{ item.showPopup ? 'color:' + activeColor : '' }}">
+            <view class="van-ellipsis">
+                {{ computed.displayTitle(item) }}
+            </view>
+        </view>
     </view>
-  </view>
 
-  <slot />
-</view>
+    <slot />
+</view>