Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

使用Viewer组件形式,第二次打开时,里面图片位置总是前一次得位置,如何每次打开要初始化位置为第一张图片? #355

Open
fengyunwudi1991 opened this issue Dec 10, 2024 · 3 comments

Comments

@fengyunwudi1991
Copy link

代码 <Viewer
class="images"
v-show="false"
ref="imagesDiv"
:images="images"
:options="viewOptions"
@inited="inited"
>
<template #default="scope">



{{ scope.options }}


@mirari
Copy link
Owner

mirari commented Dec 10, 2024

@fengyunwudi1991
Copy link
Author

在我的上面代码,在viewoption上添加initialviewindex起不到作用。我的组件是开始隐藏v-show,后面点击按钮动态给组件预览图传的图片数据。切换下一张过后,关闭,再点击还是打开是从第二个位置开始的。

@mirari
Copy link
Owner

mirari commented Dec 12, 2024

默认v-viewer会使用viewer的update方法来更新图片列表,也会保留原来的数据。
initialviewindex只在初始化时生效,v-show不会销毁v-viewer实例。

如果你的需求是点击动作打开一组图片,不需要在页面里渲染出图片列表,那可以直接改用api方式。
如果用原来的方式,也可以把点击事件改为执行view(index)方法,指定想要打开的图片索引。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants