Merge branch 'develop' of https://gitee.com/layui-vue/layui-vue into develop
This commit is contained in:
@@ -6,4 +6,4 @@ Component.install = (app: App) => {
|
||||
app.component(Component.name || 'LayCarouselItem', Component)
|
||||
}
|
||||
|
||||
export default Component as IDefineComponent
|
||||
export default Component as IDefineComponent
|
||||
@@ -12,5 +12,4 @@ const props =
|
||||
}>()
|
||||
|
||||
const active = inject('active')
|
||||
|
||||
</script>
|
||||
@@ -5,7 +5,9 @@
|
||||
</template>
|
||||
|
||||
<script setup name="LayMenu" lang="ts">
|
||||
import { defineProps, provide, ref, watch } from 'vue'
|
||||
import { computed, defineProps, provide, ref, watch } from 'vue'
|
||||
|
||||
const emit = defineEmits(['update:selectedKey', 'update:openKeys'])
|
||||
|
||||
const props = withDefaults(
|
||||
defineProps<{
|
||||
@@ -15,28 +17,46 @@ const props = withDefaults(
|
||||
}>(),
|
||||
{
|
||||
selectedKey: '',
|
||||
openKeys: function() {
|
||||
openKeys: function () {
|
||||
return []
|
||||
},
|
||||
tree: false,
|
||||
}
|
||||
)
|
||||
|
||||
const isTree = ref(props.tree)
|
||||
const selectedKey = ref(props.selectedKey)
|
||||
const openKeys = ref([...props.openKeys])
|
||||
const isTree = computed(() => props.tree)
|
||||
|
||||
const openKeys = computed({
|
||||
get() {
|
||||
return props.openKeys
|
||||
},
|
||||
set(val) {
|
||||
emit('update:selectedKey', val)
|
||||
},
|
||||
})
|
||||
|
||||
const selectedKey = computed({
|
||||
get() {
|
||||
return props.selectedKey
|
||||
},
|
||||
set(val) {
|
||||
emit('update:selectedKey', val)
|
||||
},
|
||||
})
|
||||
|
||||
watch(selectedKey, function (val) {
|
||||
emit('update:selectedKey', val)
|
||||
})
|
||||
|
||||
watch(
|
||||
openKeys,
|
||||
function (val) {
|
||||
emit('update:openKeys', val)
|
||||
},
|
||||
{ deep: true }
|
||||
)
|
||||
|
||||
provide('isTree', isTree)
|
||||
provide('selectedKey', selectedKey)
|
||||
provide('openKeys',openKeys)
|
||||
|
||||
const emit = defineEmits(['update:selectedKey','update:openKeys'])
|
||||
|
||||
watch(selectedKey, function(val) {
|
||||
emit('update:selectedKey',val)
|
||||
})
|
||||
|
||||
watch(openKeys, function(val) {
|
||||
emit('update:openKeys',val)
|
||||
},{deep : true})
|
||||
provide('openKeys', openKeys)
|
||||
</script>
|
||||
|
||||
@@ -4,11 +4,15 @@
|
||||
<li
|
||||
v-for="ss in slots"
|
||||
:key="ss"
|
||||
:class="[ss.props.id === modelValue ? 'layui-this' : '']"
|
||||
:class="[ss.props.id === active ? 'layui-this' : '']"
|
||||
@click.stop="change(ss.props.id)"
|
||||
>
|
||||
{{ ss.props.title }}
|
||||
<i @click.stop="close(ss.props.id)" v-if="allowClose" class="layui-icon layui-icon-close layui-unselect layui-tab-close"></i>
|
||||
<i
|
||||
@click.stop="close(ss.props.id)"
|
||||
v-if="allowClose"
|
||||
class="layui-icon layui-icon-close layui-unselect layui-tab-close"
|
||||
></i>
|
||||
</li>
|
||||
</ul>
|
||||
<div class="layui-tab-content">
|
||||
@@ -18,7 +22,7 @@
|
||||
</template>
|
||||
|
||||
<script setup name="LayTab" lang="ts">
|
||||
import { defineProps, provide, ref, useSlots } from 'vue'
|
||||
import { computed, defineProps, provide, ref, useSlots } from 'vue'
|
||||
|
||||
const slot = useSlots() as any
|
||||
const slots = slot.default && slot.default()
|
||||
@@ -30,17 +34,23 @@ const props = defineProps<{
|
||||
}>()
|
||||
|
||||
// select update 时, 通知 change 事件
|
||||
const emit = defineEmits(['update:modelValue','change','close'])
|
||||
const emit = defineEmits(['update:modelValue', 'change', 'close'])
|
||||
|
||||
const active = ref(props.modelValue)
|
||||
const active = computed({
|
||||
get() {
|
||||
return props.modelValue
|
||||
},
|
||||
set(val) {
|
||||
emit('update:modelValue', val)
|
||||
}
|
||||
})
|
||||
|
||||
const change = function (id: any) {
|
||||
emit('update:modelValue', id)
|
||||
emit('change', id)
|
||||
active.value = id
|
||||
}
|
||||
|
||||
const close = function(id: any) {
|
||||
const close = function (id: any) {
|
||||
emit('close', id)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user