✨(all): update
This commit is contained in:
		
							parent
							
								
									b704f90fe7
								
							
						
					
					
						commit
						044fff8d6e
					
				@ -61,7 +61,6 @@ const active = computed({
 | 
				
			|||||||
});
 | 
					});
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const change = function (id: any) {
 | 
					const change = function (id: any) {
 | 
				
			||||||
  // 回调切换标签之前的回调钩子函数,只要不是return false, 则进行切换该tab
 | 
					 | 
				
			||||||
  if (props.beforeLeave && props.beforeLeave(id) === false) {
 | 
					  if (props.beforeLeave && props.beforeLeave(id) === false) {
 | 
				
			||||||
    return;
 | 
					    return;
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
@ -70,17 +69,12 @@ const change = function (id: any) {
 | 
				
			|||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const close = function (index: number, id: any) {
 | 
					const close = function (index: number, id: any) {
 | 
				
			||||||
  // 回调关闭之前的回调函数,只要不是return false, 则进行关闭该tab
 | 
					 | 
				
			||||||
  if (props.beforeClose && props.beforeClose(id) === false) {
 | 
					  if (props.beforeClose && props.beforeClose(id) === false) {
 | 
				
			||||||
    return;
 | 
					    return;
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					 | 
				
			||||||
  // 删除当前tab
 | 
					 | 
				
			||||||
  childrens.value.splice(index, 1);
 | 
					  childrens.value.splice(index, 1);
 | 
				
			||||||
  // 点击的是当前激活的tab,则需要切换到下一个tab
 | 
					 | 
				
			||||||
  if (active.value === id) {
 | 
					  if (active.value === id) {
 | 
				
			||||||
    const nextChildren =
 | 
					    const nextChildren = childrens.value[index === childrens.value.length ? 0 : index];
 | 
				
			||||||
      childrens.value[index === childrens.value.length ? 0 : index];
 | 
					 | 
				
			||||||
    change(nextChildren && nextChildren.props ? nextChildren.props.id : "");
 | 
					    change(nextChildren && nextChildren.props ? nextChildren.props.id : "");
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
  emit("close", id);
 | 
					  emit("close", id);
 | 
				
			||||||
@ -89,7 +83,7 @@ const close = function (index: number, id: any) {
 | 
				
			|||||||
watch(slotsChange, function () {
 | 
					watch(slotsChange, function () {
 | 
				
			||||||
  childrens.value = [];
 | 
					  childrens.value = [];
 | 
				
			||||||
  setItemInstanceBySlot((slot.default && slot.default()) as VNode[]);
 | 
					  setItemInstanceBySlot((slot.default && slot.default()) as VNode[]);
 | 
				
			||||||
});
 | 
					}, { immediate: true });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
provide("active", active);
 | 
					provide("active", active);
 | 
				
			||||||
provide("slotsChange", slotsChange);
 | 
					provide("slotsChange", slotsChange);
 | 
				
			||||||
@ -102,7 +96,6 @@ provide("slotsChange", slotsChange);
 | 
				
			|||||||
      type ? 'layui-tab-' + type : '',
 | 
					      type ? 'layui-tab-' + type : '',
 | 
				
			||||||
      props.tabPosition ? `is-${tabPosition}` : '',
 | 
					      props.tabPosition ? `is-${tabPosition}` : '',
 | 
				
			||||||
    ]"
 | 
					    ]"
 | 
				
			||||||
    v-if="active"
 | 
					 | 
				
			||||||
  >
 | 
					  >
 | 
				
			||||||
    <div
 | 
					    <div
 | 
				
			||||||
      :class="['layui-tab-head', props.tabPosition ? `is-${tabPosition}` : '']"
 | 
					      :class="['layui-tab-head', props.tabPosition ? `is-${tabPosition}` : '']"
 | 
				
			||||||
@ -115,20 +108,19 @@ provide("slotsChange", slotsChange);
 | 
				
			|||||||
      >
 | 
					      >
 | 
				
			||||||
        <li
 | 
					        <li
 | 
				
			||||||
          v-for="(children, index) in childrens"
 | 
					          v-for="(children, index) in childrens"
 | 
				
			||||||
          :key="children"
 | 
					          :key="children.props?.id"
 | 
				
			||||||
          :class="[children.props.id === active ? 'layui-this' : '']"
 | 
					          :class="[children.props?.id === active ? 'layui-this' : '']"
 | 
				
			||||||
          @click.stop="change(children.props.id)"
 | 
					          @click.stop="change(children.props?.id)"
 | 
				
			||||||
        >
 | 
					        >
 | 
				
			||||||
          {{ children.props.title }}
 | 
					          {{ children.props?.title }}
 | 
				
			||||||
          <i
 | 
					          <i
 | 
				
			||||||
            v-if="allowClose && children.props.closable != false"
 | 
					            v-if="allowClose && children.props?.closable != false"
 | 
				
			||||||
            class="layui-icon layui-icon-close layui-unselect layui-tab-close"
 | 
					            class="layui-icon layui-icon-close layui-unselect layui-tab-close"
 | 
				
			||||||
            @click.stop="close(index, children.props.id)"
 | 
					            @click.stop="close(index, children.props?.id)"
 | 
				
			||||||
          ></i>
 | 
					          ></i>
 | 
				
			||||||
        </li>
 | 
					        </li>
 | 
				
			||||||
      </ul>
 | 
					      </ul>
 | 
				
			||||||
    </div>
 | 
					    </div>
 | 
				
			||||||
 | 
					 | 
				
			||||||
    <div class="layui-tab-content">
 | 
					    <div class="layui-tab-content">
 | 
				
			||||||
      <slot></slot>
 | 
					      <slot></slot>
 | 
				
			||||||
    </div>
 | 
					    </div>
 | 
				
			||||||
 | 
				
			|||||||
@ -8,11 +8,23 @@
 | 
				
			|||||||
</lay-timeline>
 | 
					</lay-timeline>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
::: demo
 | 
					::: demo
 | 
				
			||||||
 | 
					 | 
				
			||||||
<template>
 | 
					<template>
 | 
				
			||||||
  <lay-timeline>
 | 
					<lay-timeline>
 | 
				
			||||||
    <a href>前往查看</a>
 | 
					  <lay-timeline-item title="1.1.x">
 | 
				
			||||||
  </lay-timeline>
 | 
					    <ul> 
 | 
				
			||||||
 | 
					      <a name="1-1-3"></a> 
 | 
				
			||||||
 | 
					      <li> 
 | 
				
			||||||
 | 
					        <h3>1.1.3 <span class="layui-badge-rim">2022-05-21</span></h3> 
 | 
				
			||||||
 | 
					        <ul>
 | 
				
			||||||
 | 
					          <li>[新增] input 组件 clear 事件, 清空内容时触发的无参事件</li>
 | 
				
			||||||
 | 
					          <li>[修复] tab 组件初始化时, 因无法监听到 slots 变化, 而导致 layui-tab-title 无法正常显示的问题</li>
 | 
				
			||||||
 | 
					          <li>[优化] input 组件 allow-clear 触发策略, 由始终显示调整为 v-model 不为空显示</li>
 | 
				
			||||||
 | 
					          <li>[优化] icon-picker 组件 search 功能, 为 input 输入框增加清空操作</li>
 | 
				
			||||||
 | 
					        </ul> 
 | 
				
			||||||
 | 
					      </li>
 | 
				
			||||||
 | 
					    </ul>
 | 
				
			||||||
 | 
					  </lay-timeline-item>
 | 
				
			||||||
 | 
					</lay-timeline>
 | 
				
			||||||
</template>
 | 
					</template>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
<script>
 | 
					<script>
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user