Usage
Basic usage
- Use 
AsImageasAsTransition'simagesslot - Use image index as parameter to call scoped variable 
toGroupWithIndexwhich is a function, and then use the return value asAsImage'sto-groupproperty to bind image resource. 
Example
<template>
  <AsTransition>
    <template
      #images="{
        toGroupWithIndex
      }"
    >
      <AsImage
        class="demoimage"
        v-for="(src, index) in imagelist"
        :key="index"
        :to-group="toGroupWithIndex(index)"
        :width="999"
        :height="1424"
        :src="src"
      >
      </AsImage>
    </template>
  </AsTransition>
</template>
Use the built-in image transition
- Setup 
transition, More 
<template>
  <AsTransition
    :transition="{
      name: 'directionalwrap'
    }"
  >
    <template
      #images="{
        toGroupWithIndex
      }"
    >
      <AsImage
        class="demoimage"
        v-for="(src, index) in imagelist"
        :key="index"
        :to-group="toGroupWithIndex(index)"
        :width="999"
        :height="1424"
        :src="src"
      >
      </AsImage>
    </template>
  </AsTransition>
</template>
Control image switching
- Use component methods 
prevandnextto switch image - Use component methods 
setActiveIndexto switch to the specified image - Listen 
changeevent, getcurrentIndexandpreviousIndex 
// vue3 setup
<script lang="ts" setup>
const activeIndex = ref(0)
const transitionRef = ref<typeof AsTransition>()
const next = () => {
  transitionRef.value?.next()
}
const prev = () => {
  transitionRef.value?.prev()
}
const setActiveItem = () => {
  transitionRef.value?.setActiveItem(2)
}
const onChange = (activeIndex, oldIndex) => {
  activeIndex.value = activeIndex
}
</script>
Attributes
initial-index
- 
Type:
number - 
Default:
0Initial Image Index
 
speed
- 
Type:
number - 
Default:
50Switching animation speed
 
auto-play
- 
Type:
boolean - 
Default:
trueAutomatic image switching
 
interval
- 
Type:
number - 
Default:
3000Interval between auto switching
 
transition
- 
Type:
Transition - 
Default:
{ name: 'default' }Image transition effect
 
Methods
prev
The last slide
next
Next slide
setActiveIndex
- Parameter:
- Image index to switch, starting at 0
 
 
Events
change
- Callback Parameter:
- Index of currently active slide
 - Index to last slide
 
 
Example
Loading CodeSandbox...