2024-04-20 08:49:23 +00:00
..

import{o as t,a,y as e}from"./vue-libs.b44bc779.js";const n={class:"van-doc-markdown-body"},d=e(`<h1>ImagePreview \u56FE\u7247\u9884\u89C8</h1><div class="van-doc-card"><h3 id="jie-shao" tabindex="-1">\u4ECB\u7ECD</h3><p>\u56FE\u7247\u653E\u5927\u9884\u89C8\uFF0C\u652F\u6301\u51FD\u6570\u8C03\u7528\u548C\u7EC4\u4EF6\u8C03\u7528\u4E24\u79CD\u65B9\u5F0F\u3002</p></div><div class="van-doc-card"><h3 id="han-shu-diao-yong" tabindex="-1">\u51FD\u6570\u8C03\u7528</h3><p><code>ImagePreview</code> \u662F\u4E00\u4E2A\u51FD\u6570\uFF0C\u8C03\u7528\u51FD\u6570\u540E\u4F1A\u76F4\u63A5\u5728\u9875\u9762\u4E2D\u5C55\u793A\u56FE\u7247\u9884\u89C8\u754C\u9762\u3002</p><pre><code class="language-js"><span class="hljs-keyword">import</span> { <span class="hljs-title class_">ImagePreview</span> } <span class="hljs-keyword">from</span> <span class="hljs-string">&#39;vant&#39;</span>;

<span class="hljs-title class_">ImagePreview</span>([<span class="hljs-string">&#39;https://fastly.jsdelivr.net/npm/@vant/assets/apple-1.jpeg&#39;</span>]);
</code></pre><h4 id="shou-dong-yin-ru-yang-shi" tabindex="-1">\u624B\u52A8\u5F15\u5165\u6837\u5F0F</h4><p>ImagePreview \u7EC4\u4EF6\u662F\u4EE5\u51FD\u6570\u5F62\u5F0F\u63D0\u4F9B\u7684\uFF0C\u5982\u679C\u9879\u76EE\u4E2D\u4F7F\u7528 <code>unplugin-vue-components</code> \u63D2\u4EF6\u6765\u81EA\u52A8\u5F15\u5165\u7EC4\u4EF6\u6837\u5F0F\uFF0C\u5219\u65E0\u6CD5\u6B63\u786E\u8BC6\u522B ImagePreview \u7EC4\u4EF6\uFF0C\u56E0\u6B64\u9700\u8981\u624B\u52A8\u5F15\u5165 ImagePreview \u7EC4\u4EF6\u7684\u6837\u5F0F\uFF1A</p><pre><code class="language-js"><span class="hljs-keyword">import</span> <span class="hljs-string">&#39;vant/es/image-preview/style&#39;</span>;
</code></pre><p>\u4F60\u53EF\u4EE5\u5728\u9879\u76EE\u7684\u5165\u53E3\u6587\u4EF6\u6216\u516C\u5171\u6A21\u5757\u4E2D\u5F15\u5165 ImagePreview \u7EC4\u4EF6\u7684\u6837\u5F0F\uFF0C\u8FD9\u6837\u5728\u4E1A\u52A1\u4EE3\u7801\u4E2D\u4F7F\u7528 ImagePreview \u65F6\uFF0C\u4FBF\u4E0D\u518D\u9700\u8981\u91CD\u590D\u5F15\u5165\u6837\u5F0F\u4E86\u3002</p></div><div class="van-doc-card"><h3 id="zu-jian-diao-yong" tabindex="-1">\u7EC4\u4EF6\u8C03\u7528</h3><p>\u901A\u8FC7\u7EC4\u4EF6\u8C03\u7528 <code>ImagePreview</code> \u65F6\uFF0C\u53EF\u4EE5\u901A\u8FC7\u4E0B\u9762\u7684\u65B9\u5F0F\u8FDB\u884C\u6CE8\u518C\u3002</p><pre><code class="language-js"><span class="hljs-keyword">import</span> { createApp } <span class="hljs-keyword">from</span> <span class="hljs-string">&#39;vue&#39;</span>;
<span class="hljs-keyword">import</span> { <span class="hljs-title class_">ImagePreview</span> } <span class="hljs-keyword">from</span> <span class="hljs-string">&#39;vant&#39;</span>;

<span class="hljs-comment">// \u5168\u5C40\u6CE8\u518C</span>
<span class="hljs-keyword">const</span> app = <span class="hljs-title function_">createApp</span>();
app.<span class="hljs-title function_">use</span>(<span class="hljs-title class_">ImagePreview</span>);

<span class="hljs-comment">// \u5C40\u90E8\u6CE8\u518C</span>
<span class="hljs-keyword">export</span> <span class="hljs-keyword">default</span> {
  <span class="hljs-attr">components</span>: {
    [<span class="hljs-title class_">ImagePreview</span>.<span class="hljs-property">Component</span>.<span class="hljs-property">name</span>]: <span class="hljs-title class_">ImagePreview</span>.<span class="hljs-property">Component</span>,
  },
};
</code></pre><p>\u5728 <code>script setup</code> \u4E2D\uFF0C\u53EF\u4EE5\u901A\u8FC7\u4EE5\u4E0B\u65B9\u5F0F\u4F7F\u7528\uFF1A</p><pre><code class="language-html"><span class="hljs-tag">&lt;<span class="hljs-name">script</span> <span class="hljs-attr">setup</span>&gt;</span><span class="language-javascript">
  <span class="hljs-keyword">const</span> <span class="hljs-title class_">VanImagePreview</span> = <span class="hljs-title class_">ImagePreview</span>.<span class="hljs-property">Component</span>;
</span><span class="hljs-tag">&lt;/<span class="hljs-name">script</span>&gt;</span>

<span class="hljs-tag">&lt;<span class="hljs-name">template</span>&gt;</span>
  <span class="hljs-comment">&lt;!-- \u4E2D\u5212\u7EBF\u547D\u540D --&gt;</span>
  <span class="hljs-tag">&lt;<span class="hljs-name">van-image-preview</span> /&gt;</span>
  <span class="hljs-comment">&lt;!-- \u4E5F\u652F\u6301\u5927\u9A7C\u5CF0\u547D\u540D --&gt;</span>
  <span class="hljs-tag">&lt;<span class="hljs-name">VanImagePreview</span>&gt;</span>
<span class="hljs-tag">&lt;/<span class="hljs-name">template</span>&gt;</span>
</code></pre></div><h2 id="dai-ma-yan-shi" tabindex="-1">\u4EE3\u7801\u6F14\u793A</h2><div class="van-doc-card"><h3 id="ji-chu-yong-fa" tabindex="-1">\u57FA\u7840\u7528\u6CD5</h3><p>\u76F4\u63A5\u4F20\u5165\u56FE\u7247\u6570\u7EC4\uFF0C\u5373\u53EF\u5C55\u793A\u56FE\u7247\u9884\u89C8\u3002</p><pre><code class="language-js"><span class="hljs-title class_">ImagePreview</span>([
  <span class="hljs-string">&#39;https://fastly.jsdelivr.net/npm/@vant/assets/apple-1.jpeg&#39;</span>,
  <span class="hljs-string">&#39;https://fastly.jsdelivr.net/npm/@vant/assets/apple-2.jpeg&#39;</span>,
]);
</code></pre></div><div class="van-doc-card"><h3 id="zhi-ding-chu-shi-wei-zhi" tabindex="-1">\u6307\u5B9A\u521D\u59CB\u4F4D\u7F6E</h3><p><code>ImagePreview</code> \u652F\u6301\u4F20\u5165\u914D\u7F6E\u5BF9\u8C61\uFF0C\u5E76\u901A\u8FC7 <code>startPosition</code> \u9009\u9879\u6307\u5B9A\u56FE\u7247\u7684\u521D\u59CB\u4F4D\u7F6E\uFF08\u7D22\u5F15\u503C\uFF09\u3002</p><pre><code class="language-js"><span class="hljs-title class_">ImagePreview</span>({
  <span class="hljs-attr">images</span>: [
    <span class="hljs-string">&#39;https://fastly.jsdelivr.net/npm/@vant/assets/apple-1.jpeg&#39;</span>,
    <span class="hljs-string">&#39;https://fastly.jsdelivr.net/npm/@vant/assets/apple-2.jpeg&#39;</span>,
  ],
  <span class="hljs-attr">startPosition</span>: <span class="hljs-number">1</span>,
});
</code></pre></div><div class="van-doc-card"><h3 id="zhan-shi-guan-bi-an-niu" tabindex="-1">\u5C55\u793A\u5173\u95ED\u6309\u94AE</h3><p>\u8BBE\u7F6E <code>closeable</code> \u5C5E\u6027\u540E\uFF0C\u4F1A\u5728\u5F39\u51FA\u5C42\u7684\u53F3\u4E0A\u89D2\u663E\u793A\u5173\u95ED\u56FE\u6807\uFF0C\u5E76\u4E14\u53EF\u4EE5\u901A\u8FC7 <code>close-icon</code> \u5C5E\u6027\u81EA\u5B9A\u4E49\u56FE\u6807\uFF0C\u4F7F\u7528<code>close-icon-position</code> \u5C5E\u6027\u53EF\u4EE5\u81EA\u5B9A\u4E49\u56FE\u6807\u4F4D\u7F6E\u3002</p><pre><code class="language-js"><span class="hljs-title class_">ImagePreview</span>({
  <span class="hljs-attr">images</span>: [
    <span class="hljs-string">&#39;https://fastly.jsdelivr.net/npm/@vant/assets/apple-1.jpeg&#39;</span>,
    <span class="hljs-string">&#39;https://fastly.jsdelivr.net/npm/@vant/assets/apple-2.jpeg&#39;</span>,
  ],
  <span class="hljs-attr">closeable</span>: <span class="hljs-literal">true</span>,
});
</code></pre></div><div class="van-doc-card"><h3 id="jian-ting-guan-bi-shi-jian" tabindex="-1">\u76D1\u542C\u5173\u95ED\u4E8B\u4EF6</h3><p>\u901A\u8FC7 <code>onClose</code> \u9009\u9879\u76D1\u542C\u56FE\u7247\u9884\u89C8\u7684\u5173\u95ED\u4E8B\u4EF6\u3002</p><pre><code class="language-js"><span class="hljs-keyword">import</span> { <span class="hljs-title class_">Toast</span> } <span class="hljs-keyword">from</span> <span class="hljs-string">&#39;vant&#39;</span>;

<span class="hljs-title class_">ImagePreview</span>({
  <span class="hljs-attr">images</span>: [
    <span class="hljs-string">&#39;https://fastly.jsdelivr.net/npm/@vant/assets/apple-1.jpeg&#39;</span>,
    <span class="hljs-string">&#39;https://fastly.jsdelivr.net/npm/@vant/assets/apple-2.jpeg&#39;</span>,
  ],
  <span class="hljs-title function_">onClose</span>(<span class="hljs-params"></span>) {
    <span class="hljs-title class_">Toast</span>(<span class="hljs-string">&#39;\u5173\u95ED&#39;</span>);
  },
});
</code></pre></div><div class="van-doc-card"><h3 id="yi-bu-guan-bi" tabindex="-1">\u5F02\u6B65\u5173\u95ED</h3><p>\u901A\u8FC7 <code>beforeClose</code> \u5C5E\u6027\u53EF\u4EE5\u62E6\u622A\u5173\u95ED\u884C\u4E3A\u3002</p><pre><code class="language-js"><span class="hljs-keyword">const</span> instance = <span class="hljs-title class_">ImagePreview</span>({
  <span class="hljs-attr">images</span>: [
    <span class="hljs-string">&#39;https://fastly.jsdelivr.net/npm/@vant/assets/apple-1.jpeg&#39;</span>,
    <span class="hljs-string">&#39;https://fastly.jsdelivr.net/npm/@vant/assets/apple-2.jpeg&#39;</span>,
  ],
  <span class="hljs-attr">beforeClose</span>: <span class="hljs-function">() =&gt;</span> <span class="hljs-literal">false</span>,
});

<span class="hljs-built_in">setTimeout</span>(<span class="hljs-function">() =&gt;</span> {
  <span class="hljs-comment">// \u8C03\u7528\u5B9E\u4F8B\u4E0A\u7684 close \u65B9\u6CD5\u624B\u52A8\u5173\u95ED\u56FE\u7247\u9884\u89C8</span>
  instance.<span class="hljs-title function_">close</span>();
}, <span class="hljs-number">2000</span>);
</code></pre></div><div class="van-doc-card"><h3 id="zu-jian-diao-yong-1" tabindex="-1">\u7EC4\u4EF6\u8C03\u7528</h3><p>\u5982\u679C\u9700\u8981\u5728\u56FE\u7247\u9884\u89C8\u5185\u5D4C\u5165\u7EC4\u4EF6\u6216\u5176\u4ED6\u81EA\u5B9A\u4E49\u5185\u5BB9\uFF0C\u53EF\u4EE5\u4F7F\u7528\u7EC4\u4EF6\u8C03\u7528\u7684\u65B9\u5F0F\uFF0C\u8C03\u7528\u524D\u9700\u8981\u901A\u8FC7 <code>app.use</code> \u6CE8\u518C\u7EC4\u4EF6\u3002</p><pre><code class="language-html"><span class="hljs-tag">&lt;<span class="hljs-name">van-image-preview</span> <span class="hljs-attr">v-model:show</span>=<span class="hljs-string">&quot;show&quot;</span> <span class="hljs-attr">:images</span>=<span class="hljs-string">&quot;images&quot;</span> @<span class="hljs-attr">change</span>=<span class="hljs-string">&quot;onChange&quot;</span>&gt;</span>
  <span class="hljs-tag">&lt;<span class="hljs-name">template</span> <span class="hljs-attr">v-slot:index</span>&gt;</span>\u7B2C{{ index }}\u9875<span class="hljs-tag">&lt;/<span class="hljs-name">template</span>&gt;</span>
<span class="hljs-tag">&lt;/<span class="hljs-name">van-image-preview</span>&gt;</span>
</code></pre><pre><code class="language-js"><span class="hljs-keyword">import</span> { ref } <span class="hljs-keyword">from</span> <span class="hljs-string">&#39;vue&#39;</span>;

<span class="hljs-keyword">export</span> <span class="hljs-keyword">default</span> {
  <span class="hljs-title function_">setup</span>(<span class="hljs-params"></span>) {
    <span class="hljs-keyword">const</span> show = <span class="hljs-title function_">ref</span>(<span class="hljs-literal">false</span>);
    <span class="hljs-keyword">const</span> index = <span class="hljs-title function_">ref</span>(<span class="hljs-number">0</span>);
    <span class="hljs-keyword">const</span> images = [
      <span class="hljs-string">&#39;https://fastly.jsdelivr.net/npm/@vant/assets/apple-1.jpeg&#39;</span>,
      <span class="hljs-string">&#39;https://fastly.jsdelivr.net/npm/@vant/assets/apple-2.jpeg&#39;</span>,
    ];
    <span class="hljs-keyword">const</span> <span class="hljs-title function_">onChange</span> = (<span class="hljs-params">newIndex</span>) =&gt; {
      index.<span class="hljs-property">value</span> = newIndex;
    };

    <span class="hljs-keyword">return</span> {
      show,
      index,
      images,
      onChange,
    };
  },
};
</code></pre></div><div class="van-doc-card"><h3 id="shi-yong-image-cha-cao" tabindex="-1">\u4F7F\u7528 image \u63D2\u69FD</h3><p>\u5F53\u4EE5\u7EC4\u4EF6\u8C03\u7528\u7684\u65B9\u5F0F\u4F7F\u7528 ImagePreview \u65F6\uFF0C\u53EF\u4EE5\u901A\u8FC7 <code>image</code> \u63D2\u69FD\u6765\u63D2\u5165\u81EA\u5B9A\u4E49\u7684\u5185\u5BB9\uFF0C\u6BD4\u5982\u5C55\u793A\u4E00\u4E2A\u89C6\u9891\u5185\u5BB9\u3002</p><pre><code class="language-html"><span class="hljs-tag">&lt;<span class="hljs-name">van-image-preview</span> <span class="hljs-attr">v-model:show</span>=<span class="hljs-string">&quot;show&quot;</span> <span class="hljs-attr">:images</span>=<span class="hljs-string">&quot;images&quot;</span>&gt;</span>
  <span class="hljs-tag">&lt;<span class="hljs-name">template</span> #<span class="hljs-attr">image</span>=<span class="hljs-string">&quot;{ src }&quot;</span>&gt;</span>
    <span class="hljs-tag">&lt;<span class="hljs-name">video</span> <span class="hljs-attr">style</span>=<span class="hljs-string">&quot;width: 100%;&quot;</span> <span class="hljs-attr">controls</span>&gt;</span>
      <span class="hljs-tag">&lt;<span class="hljs-name">source</span> <span class="hljs-attr">:src</span>=<span class="hljs-string">&quot;src&quot;</span> /&gt;</span>
    <span class="hljs-tag">&lt;/<span class="hljs-name">video</span>&gt;</span>
  <span class="hljs-tag">&lt;/<span class="hljs-name">template</span>&gt;</span>
<span class="hljs-tag">&lt;/<span class="hljs-name">van-image-preview</span>&gt;</span>
</code></pre><pre><code class="language-js"><span class="hljs-keyword">import</span> { ref } <span class="hljs-keyword">from</span> <span class="hljs-string">&#39;vue&#39;</span>;

<span class="hljs-keyword">export</span> <span class="hljs-keyword">default</span> {
  <span class="hljs-title function_">setup</span>(<span class="hljs-params"></span>) {
    <span class="hljs-keyword">const</span> show = <span class="hljs-title function_">ref</span>(<span class="hljs-literal">false</span>);
    <span class="hljs-keyword">const</span> images = [
      <span class="hljs-string">&#39;https://www.w3school.com.cn/i/movie.ogg&#39;</span>,
      <span class="hljs-string">&#39;https://www.w3school.com.cn/i/movie.ogg&#39;</span>,
      <span class="hljs-string">&#39;https://www.w3school.com.cn/i/movie.ogg&#39;</span>,
    ];
    <span class="hljs-keyword">return</span> {
      show,
      images,
    };
  },
};
</code></pre></div><h2 id="api" tabindex="-1">API</h2><div class="van-doc-card"><h3 id="options" tabindex="-1">Options</h3><p>\u901A\u8FC7\u51FD\u6570\u8C03\u7528 <code>ImagePreview</code> \u65F6\uFF0C\u652F\u6301\u4F20\u5165\u4EE5\u4E0B\u9009\u9879\uFF1A</p><table><thead><tr><th>\u53C2\u6570\u540D</th><th>\u8BF4\u660E</th><th>\u7C7B\u578B</th><th>\u9ED8\u8BA4\u503C</th></tr></thead><tbody><tr><td>images</td><td>\u9700\u8981\u9884\u89C8\u7684\u56FE\u7247 URL \u6570\u7EC4</td><td><em>string[]</em></td><td><code>[]</code></td></tr><tr><td>startPosition</td><td>\u56FE\u7247\u9884\u89C8\u8D77\u59CB\u4F4D\u7F6E\u7D22\u5F15</td><td><em>number | string</em></td><td><code>0</code></td></tr><tr><td>swipeDuration</td><td>\u52A8\u753B\u65F6\u957F\uFF0C\u5355\u4F4D\u4E3A <code>ms</code></td><td><em>number | string</em></td><td><code>300</code></td></tr><tr><td>showIndex</td><td>\u662F\u5426\u663E\u793A\u9875\u7801</td><td><em>boolean</em></td><td><code>true</code></td></tr><tr><td>showIndicators</td><td>\u662F\u5426\u663E\u793A\u8F6E\u64AD\u6307\u793A\u5668</td><td><em>boolean</em></td><td><code>false</code></td></tr><tr><td>loop</td><td>\u662F\u5426\u5F00\u542F\u5FAA\u73AF\u64AD\u653E</td><td><em>boolean</em></td><td><code>true</code></td></tr><tr><td>onClose</td><td>\u5173\u95ED\u65F6\u7684\u56DE\u8C03\u51FD\u6570</td><td><em>Function</em></td><td>-</td></tr><tr><td>onChange</td><td>\u5207\u6362\u56FE\u7247\u65F6\u7684\u56DE\u8C03\u51FD\u6570\uFF0C\u56DE\u8C03\u53C2\u6570\u4E3A\u5F53\u524D\u7D22\u5F15</td><td><em>Function</em></td><td>-</td></tr><tr><td>onScale</td><td>\u7F29\u653E\u56FE\u7247\u65F6\u7684\u56DE\u8C03\u51FD\u6570\uFF0C\u56DE\u8C03\u53C2\u6570\u4E3A\u5F53\u524D\u7D22\u5F15\u548C\u5F53\u524D\u7F29\u653E\u503C\u7EC4\u6210\u7684\u5BF9\u8C61</td><td><em>Function</em></td><td>-</td></tr><tr><td>beforeClose</td><td>\u5173\u95ED\u524D\u7684\u56DE\u8C03\u51FD\u6570\uFF0C\u8FD4\u56DE <code>false</code> \u53EF\u963B\u6B62\u5173\u95ED\uFF0C\u652F\u6301\u8FD4\u56DE Promise</td><td><em>(active: number) =&gt; boolean | Promise&lt;boolean&gt;</em></td><td>-</td></tr><tr><td>closeOnPopstate</td><td>\u662F\u5426\u5728\u9875\u9762\u56DE\u9000\u65F6\u81EA\u52A8\u5173\u95ED</td><td><em>boolean</em></td><td><code>true</code></td></tr><tr><td>className</td><td>\u81EA\u5B9A\u4E49\u7C7B\u540D</td><td><em>string | Array | object</em></td><td>-</td></tr><tr><td>maxZoom</td><td>\u624B\u52BF\u7F29\u653E\u65F6\uFF0C\u6700\u5927\u7F29\u653E\u6BD4\u4F8B</td><td><em>number | string</em></td><td><code>3</code></td></tr><tr><td>minZoom</td><td>\u624B\u52BF\u7F29\u653E\u65F6\uFF0C\u6700\u5C0F\u7F29\u653E\u6BD4\u4F8B</td><td><em>number | string</em></td><td><code>1/3</code></td></tr><tr><td>closeable</td><td>\u662F\u5426\u663E\u793A\u5173\u95ED\u56FE\u6807</td><td><em>boolean</em></td><td><code>false</code></td></tr><tr><td>closeIcon</td><td>\u5173\u95ED\u56FE\u6807\u540D\u79F0\u6216\u56FE\u7247\u94FE\u63A5</td><td><em>string</em></td><td><code>clear</code></td></tr><tr><td>closeIconPosition</td><td>\u5173\u95ED\u56FE\u6807\u4F4D\u7F6E\uFF0C\u53EF\u9009\u503C\u4E3A <code>top-left</code><br><code>bottom-left</code> <code>bottom-right</code></td><td><em>string</em></td><td><code>top-right</code></td></tr><tr><td>transition <code>v3.0.8</code></td><td>\u52A8\u753B\u7C7B\u540D\uFF0C\u7B49\u4EF7\u4E8E <a href="https://v3.cn.vuejs.org/api/built-in-components.html#transition" target="_blank">transition</a> \u7684 <code>name</code> \u5C5E\u6027</td><td><em>string</em></td><td><code>van-fade</code></td></tr><tr><td>overlayClass <code>v3.2.8</code></td><td>\u81EA\u5B9A\u4E49\u906E\u7F69\u5C42\u7C7B\u540D</td><td><em>string | Array | object</em></td><td>-</td></tr><tr><td>overlayStyle <code>v3.0.8</code></td><td>\u81EA\u5B9A\u4E49\u906E\u7F69\u5C42\u6837\u5F0F</td><td><em>object</em></td><td>-</td></tr><tr><td>teleport</td><td>\u6307\u5B9A\u6302\u8F7D\u7684\u8282\u70B9\uFF0C\u7B49\u540C\u4E8E Teleport \u7EC4\u4EF6\u7684 <a href="https://v3.cn.vuejs.org/api/built-in-components.html#teleport" target="_blank">to \u5C5E\u6027</a></td><td><em>string | Element</em></td><td>-</td></tr></tbody></table></div><div class="van-doc-card"><h3 id="props" tabindex="-1">Props</h3><p>\u901A\u8FC7\u7EC4\u4EF6\u8C03\u7528 <code>ImagePreview</code> \u65F6\uFF0C\u652F\u6301\u4EE5\u4E0B Props\uFF1A</p><table><thead><tr><th>\u53C2\u6570</th><th>\u8BF4\u660E</th><th>\u7C7B\u578B</th><th>\u9ED8\u8BA4\u503C</th></tr></thead><tbody><tr><td>v-model:show</td><td>\u662F\u5426\u5C55\u793A\u56FE\u7247\u9884\u89C8</td><td><em>boolean</em></td><td><code>false</code></td></tr><tr><td>images</td><td>\u9700\u8981\u9884\u89C8\u7684\u56FE\u7247 URL \u6570\u7EC4</td><td><em>string[]</em></td><td><code>[]</code></td></tr><tr><td>start-position</td><td>\u56FE\u7247\u9884\u89C8\u8D77\u59CB\u4F4D\u7F6E\u7D22\u5F15</td><td><em>number | string</em></td><td><code>0</code></td></tr><tr><td>swipe-duration</td><td>\u52A8\u753B\u65F6\u957F\uFF0C\u5355\u4F4D\u4E3A ms</td><td><em>number | string</em></td><td><code>300</code></td></tr><tr><td>show-index</td><td>\u662F\u5426\u663E\u793A\u9875\u7801</td><td><em>boolean</em></td><td><code>true</code></td></tr><tr><td>show-indicators</td><td>\u662F\u5426\u663E\u793A\u8F6E\u64AD\u6307\u793A\u5668</td><td><em>boolean</em></td><td><code>false</code></td></tr><tr><td>loop</td><td>\u662F\u5426\u5F00\u542F\u5FAA\u73AF\u64AD\u653E</td><td><em>boolean</em></td><td><code>true</code></td></tr><tr><td>before-close</td><td>\u5173\u95ED\u524D\u7684\u56DE\u8C03\u51FD\u6570\uFF0C\u8FD4\u56DE <code>false</code> \u53EF\u963B\u6B62\u5173\u95ED\uFF0C\u652F\u6301\u8FD4\u56DE Promise</td><td><em>(active: number) =&gt; boolean | Promise&lt;boolean&gt;</em></td><td>-</td></tr><tr><td>close-on-popstate</td><td>\u662F\u5426\u5728\u9875\u9762\u56DE\u9000\u65F6\u81EA\u52A8\u5173\u95ED</td><td><em>boolean</em></td><td><code>true</code></td></tr><tr><td>class-name</td><td>\u81EA\u5B9A\u4E49\u7C7B\u540D</td><td><em>string | Array | object</em></td><td>-</td></tr><tr><td>max-zoom</td><td>\u624B\u52BF\u7F29\u653E\u65F6\uFF0C\u6700\u5927\u7F29\u653E\u6BD4\u4F8B</td><td><em>number | string</em></td><td><code>3</code></td></tr><tr><td>min-zoom</td><td>\u624B\u52BF\u7F29\u653E\u65F6\uFF0C\u6700\u5C0F\u7F29\u653E\u6BD4\u4F8B</td><td><em>number | string</em></td><td><code>1/3</code></td></tr><tr><td>closeable</td><td>\u662F\u5426\u663E\u793A\u5173\u95ED\u56FE\u6807</td><td><em>boolean</em></td><td><code>false</code></td></tr><tr><td>close-icon</td><td>\u5173\u95ED\u56FE\u6807\u540D\u79F0\u6216\u56FE\u7247\u94FE\u63A5</td><td><em>string</em></td><td><code>clear</code></td></tr><tr><td>close-icon-position</td><td>\u5173\u95ED\u56FE\u6807\u4F4D\u7F6E\uFF0C\u53EF\u9009\u503C\u4E3A <code>top-left</code><br><code>bottom-left</code> <code>bottom-right</code></td><td><em>string</em></td><td><code>top-right</code></td></tr><tr><td>transition <code>v3.0.8</code></td><td>\u52A8\u753B\u7C7B\u540D\uFF0C\u7B49\u4EF7\u4E8E <a href="https://v3.cn.vuejs.org/api/built-in-components.html#transition" target="_blank">transition</a> \u7684 <code>name</code> \u5C5E\u6027</td><td><em>string</em></td><td><code>van-fade</code></td></tr><tr><td>overlay-class <code>v3.2.8</code></td><td>\u81EA\u5B9A\u4E49\u906E\u7F69\u5C42\u7C7B\u540D</td><td><em>string | Array | object</em></td><td>-</td></tr><tr><td>overlay-style <code>v3.0.8</code></td><td>\u81EA\u5B9A\u4E49\u906E\u7F69\u5C42\u6837\u5F0F</td><td><em>object</em></td><td>-</td></tr><tr><td>teleport</td><td>\u6307\u5B9A\u6302\u8F7D\u7684\u8282\u70B9\uFF0C\u7B49\u540C\u4E8E Teleport \u7EC4\u4EF6\u7684 <a href="https://v3.cn.vuejs.org/api/built-in-components.html#teleport" target="_blank">to \u5C5E\u6027</a></td><td><em>string | Element</em></td><td>-</td></tr></tbody></table></div><div class="van-doc-card"><h3 id="events" tabindex="-1">Events</h3><p>\u901A\u8FC7\u7EC4\u4EF6\u8C03\u7528 <code>ImagePreview</code> \u65F6\uFF0C\u652F\u6301\u4EE5\u4E0B\u4E8B\u4EF6\uFF1A</p><table><thead><tr><th>\u4E8B\u4EF6</th><th>\u8BF4\u660E</th><th>\u56DE\u8C03\u53C2\u6570</th></tr></thead><tbody><tr><td>close</td><td>\u5173\u95ED\u65F6\u89E6\u53D1</td><td>{ index: \u7D22\u5F15, url: \u56FE\u7247\u94FE\u63A5 }</td></tr><tr><td>closed</td><td>\u5173\u95ED\u4E14\u4E14\u52A8\u753B\u7ED3\u675F\u540E\u89E6\u53D1</td><td>-</td></tr><tr><td>change</td><td>\u5207\u6362\u5F53\u524D\u56FE\u7247\u65F6\u89E6\u53D1</td><td>index: \u5F53\u524D\u56FE\u7247\u7684\u7D22\u5F15</td></tr><tr><td>scale</td><td>\u7F29\u653E\u5F53\u524D\u56FE\u7247\u65F6\u89E6\u53D1</td><td>{ index: \u5F53\u524D\u56FE\u7247\u7684\u7D22\u5F15, scale: \u5F53\u524D\u7F29\u653E\u7684\u503C }</td></tr></tbody></table></div><div class="van-doc-card"><h3 id="fang-fa" tabindex="-1">\u65B9\u6CD5</h3><p>\u901A\u8FC7\u7EC4\u4EF6\u8C03\u7528 <code>ImagePreview</code> \u65F6\uFF0C\u901A\u8FC7 ref \u53EF\u4EE5\u83B7\u53D6\u5230 ImagePreview \u5B9E\u4F8B\u5E76\u8C03\u7528\u5B9E\u4F8B\u65B9\u6CD5\uFF0C\u8BE6\u89C1<a href="#/zh-CN/advanced-usage#zu-jian-shi-li-fang-fa" target="_blank">\u7EC4\u4EF6\u5B9E\u4F8B\u65B9\u6CD5</a>\u3002</p><table><thead><tr><th>\u65B9\u6CD5\u540D</th><th>\u8BF4\u660E</th><th>\u53C2\u6570</th><th>\u8FD4\u56DE\u503C</th></tr></thead><tbody><tr><td>swipeTo <code>2.9.0</code></td><td>\u5207\u6362\u5230\u6307\u5B9A\u4F4D\u7F6E</td><td><em>index: number, options?: SwipeToOptions</em></td><td>-</td></tr></tbody></table></div><div class="van-doc-card"><h3 id="lei-xing-ding-yi" tabindex="-1">\u7C7B\u578B\u5B9A\u4E49</h3><p>\u7EC4\u4EF6\u5BFC\u51FA\u4EE5\u4E0B\u7C7B\u578B\u5B9A\u4E49\uFF1A</p><pre><code class="language-ts"><span class="hljs-keyword">import</span> <span class="hljs-keyword">type</span> {
  <span class="hljs-title class_">ImagePreviewProps</span>,
  <span class="hljs-title class_">ImagePreviewOptions</span>,
  <span class="hljs-title class_">ImagePreviewInstance</span>,
  <span class="hljs-title class_">ImagePreviewScaleEventParams</span>,
} <span class="hljs-keyword">from</span> <span class="hljs-string">&#39;vant&#39;</span>;
</code></pre><p><code>ImagePreviewInstance</code> \u662F\u7EC4\u4EF6\u5B9E\u4F8B\u7684\u7C7B\u578B\uFF0C\u7528\u6CD5\u5982\u4E0B\uFF1A</p><pre><code class="language-ts"><span class="hljs-keyword">import</span> { ref } <span class="hljs-keyword">from</span> <span class="hljs-string">&#39;vue&#39;</span>;
<span class="hljs-keyword">import</span> <span class="hljs-keyword">type</span> { <span class="hljs-title class_">ImagePreviewInstance</span> } <span class="hljs-keyword">from</span> <span class="hljs-string">&#39;vant&#39;</span>;

<span class="hljs-keyword">const</span> imagePreviewRef = ref&lt;<span class="hljs-title class_">ImagePreviewInstance</span>&gt;();

imagePreviewRef.<span class="hljs-property">value</span>?.<span class="hljs-title function_">swipeTo</span>(<span class="hljs-number">1</span>);
</code></pre></div><div class="van-doc-card"><h3 id="slots" tabindex="-1">Slots</h3><p>\u901A\u8FC7\u7EC4\u4EF6\u8C03\u7528 <code>ImagePreview</code> \u65F6\uFF0C\u652F\u6301\u4EE5\u4E0B\u63D2\u69FD\uFF1A</p><table><thead><tr><th>\u540D\u79F0</th><th>\u8BF4\u660E</th><th>\u53C2\u6570</th></tr></thead><tbody><tr><td>index</td><td>\u81EA\u5B9A\u4E49\u9875\u7801\u5185\u5BB9</td><td>{ index: \u5F53\u524D\u56FE\u7247\u7684\u7D22\u5F15 }</td></tr><tr><td>cover</td><td>\u81EA\u5B9A\u4E49\u8986\u76D6\u5728\u56FE\u7247\u9884\u89C8\u4E0A\u65B9\u7684\u5185\u5BB9</td><td>-</td></tr><tr><td>image <code>v3.6.5</code></td><td>\u81EA\u5B9A\u4E49\u56FE\u7247\u5185\u5BB9</td><td>{ src: \u5F53\u524D\u8D44\u6E90\u5730\u5740 }</td></tr></tbody></table></div><div class="van-doc-card"><h3 id="onclose-hui-diao-can-shu" tabindex="-1">onClose \u56DE\u8C03\u53C2\u6570</h3><table><thead><tr><th>\u53C2\u6570\u540D</th><th>\u8BF4\u660E</th><th>\u7C7B\u578B</th></tr></thead><tbody><tr><td>url</td><td>\u5F53\u524D\u56FE\u7247 URL</td><td><em>string</em></td></tr><tr><td>index</td><td>\u5F53\u524D\u56FE\u7247\u7684\u7D22\u5F15\u503C</td><td><em>number</em></td></tr></tbody></table></div><div class="van-doc-card"><h3 id="onscale-hui-diao-can-shu" tabindex="-1">onScale \u56DE\u8C03\u53C2\u6570</h3><table><thead><tr><th>\u53C2\u6570\u540D</th><th>\u8BF4\u660E</th><th>\u7C7B\u578B</th></tr></thead><tbody><tr><td>index</td><td>\u5F53\u524D\u56FE\u7247\u7684\u7D22\u5F15\u503C</td><td><em>number</em></td></tr><tr><td>scale</td><td>\u5F53\u524D\u56FE\u7247\u7684\u7F29\u653E\u503C</td><td><em>number</em></td></tr></tbody></table></div><h2 id="zhu-ti-ding-zhi" tabindex="-1">\u4E3B\u9898\u5B9A\u5236</h2><div class="van-doc-card"><h3 id="yang-shi-bian-liang" tabindex="-1">\u6837\u5F0F\u53D8\u91CF</h3><p>\u7EC4\u4EF6\u63D0\u4F9B\u4E86\u4E0B\u5217 CSS \u53D8\u91CF\uFF0C\u53EF\u7528\u4E8E\u81EA\u5B9A\u4E49\u6837\u5F0F\uFF0C\u4F7F\u7528\u65B9\u6CD5\u8BF7\u53C2\u8003 <a href="#/zh-CN/config-provider" target="_blank">ConfigProvider \u7EC4\u4EF6</a>\u3002</p><table><thead><tr><th>\u540D\u79F0</th><th>\u9ED8\u8BA4\u503C</th><th>\u63CF\u8FF0</th></tr></thead><tbody><tr><td>--van-image-preview-index-text-color</td><td><em>var(--van-white)</em></td><td>-</td></tr><tr><td>--van-image-preview-index-font-size</td><td><em>var(--van-font-size-md)</em></td><td>-</td></tr><tr><td>--van-image-preview-index-line-height</td><td><em>var(--van-line-height-md)</em></td><td>-</td></tr><tr><td>--van-image-preview-index-text-shadow</td><td><em>0 1px 1px var(--van-gray-8)</em></td><td>-</td></tr><tr><td>--van-image-preview-overlay-background-color</td><td><em>rgba(0, 0, 0, 0.9)</em></td><td>-</td></tr><tr><td>--van-image-preview-close-icon-size</td><td><em>22px</em></td><td>-</td></tr><tr><td>--van-image-preview-close-icon-color</td><td><em>var(--van-gray-5)</em></td><td>-</td></tr><tr><td>--van-image-preview-close-icon-margin</td><td><em>var(--van-padding-md)</em></td><td>-</td></tr><tr><td>--van-image-preview-close-icon-z-index</td><td><em>1</em></td><td>-</td></tr></tbody></table></div><h2 id="chang-jian-wen-ti" tabindex="-1">\u5E38\u89C1\u95EE\u9898</h2><div class="van-doc-card"><h3 id="zai-zhuo-mian-duan-wu-fa-cao-zuo-zu-jian" tabindex="-1">\u5728\u684C\u9762\u7AEF\u65E0\u6CD5\u64CD\u4F5C\u7EC4\u4EF6\uFF1F</h3><p>\u53C2\u89C1<a href="#/zh-CN/advanced-usage#zhuo-mian-duan-gua-pei" target="_blank">\u684C\u9762\u7AEF\u9002\u914D</a>\u3002</p></div><div class="van-doc-card"><h3 id="zai-jsx-zhong-xuan-ran-imagepreview-zu-jian-wu-fa-zhan-shi" tabindex="-1">\u5728 JSX \u4E2D\u6E32\u67D3 ImagePreview \u7EC4\u4EF6\u65E0\u6CD5\u5C55\u793A\uFF1F</h3><p>\u8BF7\u6CE8\u610F <code>ImagePreview</code> \u662F\u4E00\u4E2A\u51FD\u6570\uFF0C<code>ImagePreview.Component</code> \u624D\u662F ImagePreview \u5BF9\u5E94\u7684\u7EC4\u4EF6\u3002JSX \u8C03\u7528\u56FE\u7247\u9884\u89C8\u7684\u6B63\u786E\u59FF\u52BF\u5982\u4E0B\uFF1A</p><pre><code class="language-jsx"><span class="hljs-keyword">export</span> <span class="hljs-keyword">default</span> {
  <span class="hljs-title function_">setup</span>(<span class="hljs-params"></span>) {
    <span class="hljs-keyword">const</span> show = <span class="hljs-title function_">ref</span>(<span class="hljs-literal">false</span>);
    <span class="hljs-keyword">return</span> <span class="hljs-function">() =&gt;</span> <span class="language-xml"><span class="hljs-tag">&lt;<span class="hljs-name">ImagePreview.Component</span> <span class="hljs-attr">v-model</span>=<span class="hljs-string">{[show,</span> &#39;<span class="hljs-attr">show</span>&#39;]} /&gt;</span></span>;
  },
};
</code></pre></div>`,26),l=[d],h={__name:"README.zh-CN",setup(p,{expose:s}){return s({frontmatter:{}}),(o,r)=>(t(),a("div",n,l))}};export{h as default};