{"id":96,"date":"2022-05-20T16:19:19","date_gmt":"2022-05-20T08:19:19","guid":{"rendered":"https:\/\/www.icfyless.com\/?p=96"},"modified":"2022-06-15T10:57:37","modified_gmt":"2022-06-15T02:57:37","slug":"96","status":"publish","type":"post","link":"https:\/\/www.icfyless.com\/index.php\/2022\/05\/20\/96\/","title":{"rendered":"v-viewer\u56fe\u7247\u9884\u89c8\u63d2\u4ef6"},"content":{"rendered":"<h1>v-viewer\u56fe\u7247\u9884\u89c8\u63d2\u4ef6\u7684\u4f7f\u7528<\/h1>\n<blockquote>\n<p>v-viewer\u56fe\u7247\u9884\u89c8\u7ec4\u4ef6\uff0c\u652f\u6301\u65cb\u8f6c\u7f29\u653e\uff0c\u7ffb\u8f6c\uff0c\u7b49\u64cd\u4f5c\uff0c\u4ed6\u662f\u57fa\u4e8e<a href=\"https:\/\/github.com\/fengyuanchen\/viewerjs\">viewer.js<\/a>\u505a\u7684\u4e8c\u6b21\u5f00\u53d1\uff0cgithub\u5730\u5740<a href=\"https:\/\/github.com\/mirari\/v-viewer\">https:\/\/github.com\/mirari\/v-viewer<\/a><\/p>\n<\/blockquote>\n<p><img decoding=\"async\" src=\"http:\/\/icfy-1256883275.file.myqcloud.com\/2022\/05\/20\/62874a339df9d.webp\" alt=\"\u9884\u89c8\u6548\u679c\" title=\"\u9884\u89c8\u6548\u679c\" \/><\/p>\n<h2>\u4e00\u3001\u5b89\u88c5<\/h2>\n<pre><code class=\"language-js\">npm install v-viewer --save<\/code><\/pre>\n<h2>\u4e8c\u3001\u4f7f\u7528<\/h2>\n<h3>1.\u6307\u4ee4\u65b9\u5f0f\u4f7f\u7528<\/h3>\n<blockquote>\n<p>\u53ea\u9700\u8981\u5c06v-viewer\u6307\u4ee4\u6dfb\u52a0\u5230\u4efb\u610f\u5143\u7d20\u5373\u53ef\uff0c\u8be5\u5143\u7d20\u4e0b\u7684\u6240\u6709img\u5143\u7d20\u90fd\u4f1a\u88abviewer\u81ea\u52a8\u5904\u7406\u3002\u4f60\u53ef\u4ee5\u50cf\u8fd9\u6837\u4f20\u5165\u914d\u7f6e\u9879\uff1a v-viewer=&quot;{inline: true}&quot;\u5982\u679c\u6709\u5fc5\u8981\uff0c\u53ef\u4ee5\u5148\u7528\u9009\u62e9\u5668\u67e5\u627e\u5230\u76ee\u6807\u5143\u7d20\uff0c\u7136\u540e\u53ef\u4ee5\u7528el.$viewer\u6765\u83b7\u53d6viewer\u5b9e\u4f8b\u3002<\/p>\n<\/blockquote>\n<pre><code class=\"language-vue\">&lt;template&gt;\n  &lt;div id=&quot;app&quot;&gt;\n    &lt;div class=&quot;images&quot; v-viewer=&quot;{movable: false}&quot;&gt;\n      &lt;img v-for=&quot;src in images&quot; :src=&quot;src&quot; :key=&quot;src&quot;&gt;\n    &lt;\/div&gt;\n    &lt;button type=&quot;button&quot; @click=&quot;show&quot;&gt;Show&lt;\/button&gt;\n  &lt;\/div&gt;\n&lt;\/template&gt;\n&lt;script&gt;\n  import &#039;viewerjs\/dist\/viewer.css&#039;\n  import Viewer from &#039;v-viewer&#039;\n  import Vue from &#039;vue&#039;\n  Vue.use(Viewer)\n  export default {\n    data() {\n      \/\/\u7528\u4e8e\u9884\u89c8\u7684\u56fe\u7247\u6570\u7ec4\n      images: [&#039;1.jpg&#039;, &#039;2.jpg&#039;]\n    },\n    methods: {\n      show () {\n        \/\/\u83b7\u53d6viewer\u5b9e\u4f8b\n        const viewer = this.$el.querySelector(&#039;.images&#039;).$viewer\n        \/\/\u8c03\u7528show\u65b9\u6cd5\u8fdb\u884c\u663e\u793a\u9884\u89c8\u56fe\n        viewer.show()\n      }\n    }\n  }\n&lt;\/script&gt;<\/code><\/pre>\n<h3>2.\u7ec4\u4ef6\u65b9\u5f0f\u4f7f\u7528<\/h3>\n<pre><code class=\"language-vue\">&lt;template&gt;\n  &lt;div id=&quot;app&quot;&gt;\n    &lt;viewer :options=&quot;options&quot; :images=&quot;images&quot; @inited=&quot;inited&quot; class=&quot;viewer&quot; ref=&quot;viewer&quot;&gt;\n      &lt;template scope=&quot;scope&quot;&gt;\n        &lt;img v-for=&quot;src in scope.images&quot; :src=&quot;src&quot; :key=&quot;src&quot; \/&gt;\n        {{ scope.options }}\n      &lt;\/template&gt;\n    &lt;\/viewer&gt;\n    &lt;button type=&quot;button&quot; @click=&quot;show&quot;&gt;Show&lt;\/button&gt;\n  &lt;\/div&gt;\n&lt;\/template&gt;\n&lt;script&gt;\nimport &#039;viewerjs\/dist\/viewer.css&#039;\nimport Viewer from &#039;v-viewer\/src\/component.vue&#039;\nexport default {\n  components: {\n    Viewer\n  },\n  data() {\n    images: [&#039;1.jpg&#039;, &#039;2.jpg&#039;]\n  },\n  methods: {\n    inited(viewer) {\n      this.$viewer = viewer\n    },\n    show() {\n      \/\/\u8c03\u7528$viewer\u7684show\u65b9\u6cd5\uff0c\u9ed8\u8ba4\u663e\u793a\u7b2c\u4e00\u5f20\u56fe\u7247\n      this.$viewer.show()\n      \/\/\u5982\u679c\u9700\u8981\u6307\u5b9a\u663e\u793a\u67d0\u4e00\u5f20\u56fe\u7247\u4f7f\u7528view\u65b9\u6cd5\uff0cindex\u662f\u6307\u5b9a\u7684\u90a3\u5f20\u56fe\u7247\u6240\u5728\u6570\u7ec4\u7684\u4f4d\u7f6e\u7d22\u5f15\n      \/\/this.$viewer.view(index)\n    }\n  }\n}\n&lt;\/script&gt;\n<\/code><\/pre>\n<h2>\u4e09\u3001Options\u914d\u7f6e\u9879\u8bf4\u660e<\/h2>\n<pre><code class=\"language-js\">options: {\n  inline: true, \/\/ \u662f\u5426\u542f\u7528inline\u6a21\u5f0f\n  button: true, \/\/ \u662f\u5426\u663e\u793a\u53f3\u4e0a\u89d2\u5173\u95ed\u6309\u94ae\n  navbar: true, \/\/ \u662f\u5426\u663e\u793a\u7f29\u7565\u56fe\u5e95\u90e8\u5bfc\u822a\u680f\n  title: true, \/\/ \u662f\u5426\u663e\u793a\u5f53\u524d\u56fe\u7247\u6807\u9898\uff0c\u9ed8\u8ba4\u663e\u793aalt\u5c5e\u6027\u5185\u5bb9\u548c\u5c3a\u5bf8\n  toolbar: true, \/\/ \u662f\u5426\u663e\u793a\u5de5\u5177\u680f\n  tooltip: true, \/\/ \u653e\u5927\u6216\u7f29\u5c0f\u56fe\u7247\u65f6\uff0c\u662f\u5426\u663e\u793a\u7f29\u653e\u767e\u5206\u6bd4\uff0c\u9ed8\u8ba4true\n  fullscreen: true, \/\/ \u64ad\u653e\u65f6\u662f\u5426\u5168\u5c4f\uff0c\u9ed8\u8ba4true\n  loading: true, \/\/ \u52a0\u8f7d\u56fe\u7247\u65f6\u662f\u5426\u663e\u793aloading\u56fe\u6807\uff0c\u9ed8\u8ba4true\n  loop: true, \/\/ \u662f\u5426\u53ef\u4ee5\u5faa\u73af\u67e5\u770b\u56fe\u7247\uff0c\u9ed8\u8ba4true\n  movable: true, \/\/ \u662f\u5426\u53ef\u4ee5\u62d6\u5f97\u56fe\u7247\uff0c\u9ed8\u8ba4true\n  zoomable: true, \/\/ \u662f\u5426\u53ef\u4ee5\u7f29\u653e\u56fe\u7247\uff0c\u9ed8\u8ba4true\n  rotatable: true, \/\/ \u662f\u5426\u53ef\u4ee5\u65cb\u8f6c\u56fe\u7247\uff0c\u9ed8\u8ba4true\n  scalable: true, \/\/ \u662f\u5426\u53ef\u4ee5\u7ffb\u8f6c\u56fe\u7247\uff0c\u9ed8\u8ba4true\n  toggleOnDblclick: true, \/\/ \u653e\u5927\u6216\u7f29\u5c0f\u56fe\u7247\u65f6\uff0c\u662f\u5426\u53ef\u4ee5\u53cc\u51fb\u8fd8\u539f\uff0c\u9ed8\u8ba4true\n  transition: true, \/\/ \u4f7f\u7528 CSS3 \u8fc7\u5ea6\uff0c\u9ed8\u8ba4true\n  keyboard: true, \/\/ \u662f\u5426\u652f\u6301\u952e\u76d8\uff0c\u9ed8\u8ba4true\n  zoomRatio: 0.1, \/\/ \u9f20\u6807\u6eda\u52a8\u65f6\u7684\u7f29\u653e\u6bd4\u4f8b\uff0c\u9ed8\u8ba40.1\n  minZoomRatio: 0.01, \/\/ \u6700\u5c0f\u7f29\u653e\u6bd4\u4f8b\uff0c\u9ed8\u8ba40.01\n  maxZoomRatio: 100, \/\/ \u6700\u5927\u7f29\u653e\u6bd4\u4f8b\uff0c\u9ed8\u8ba4100\n  url: &#039;data-source&#039; \/\/ \u8bbe\u7f6e\u5927\u56fe\u7247\u7684 url\n}<\/code><\/pre>\n<h2>\u56db\u3001\u5907\u6ce8<\/h2>\n<ol>\n<li><a href=\"https:\/\/mirari.cc\/2017\/08\/27\/Vue%E5%9B%BE%E7%89%87%E6%B5%8F%E8%A7%88%E7%BB%84%E4%BB%B6v-viewer%EF%BC%8C%E6%94%AF%E6%8C%81%E6%97%8B%E8%BD%AC%E3%80%81%E7%BC%A9%E6%94%BE%E3%80%81%E7%BF%BB%E8%BD%AC%E7%AD%89%E6%93%8D%E4%BD%9C\/\">\u4e2d\u6587\u6587\u6863<\/a><\/li>\n<li><a href=\"https:\/\/mirari.cc\/v-viewer\/\">\u5728\u7ebf\u6548\u679c<\/a><\/li>\n<li><a href=\"https:\/\/mirari.cc\/v-viewer\/\">\u4ee3\u7801\u793a\u4f8b<\/a><\/li>\n<\/ol>\n","protected":false},"excerpt":{"rendered":"<p>v-viewer\u56fe\u7247\u9884\u89c8\u63d2\u4ef6\u7684\u4f7f\u7528 v-viewe &hellip;<\/p>\n","protected":false},"author":1,"featured_media":97,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[7,6],"tags":[],"class_list":["post-96","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-vue","category-codeing"],"_links":{"self":[{"href":"https:\/\/www.icfyless.com\/index.php\/wp-json\/wp\/v2\/posts\/96","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.icfyless.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.icfyless.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.icfyless.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.icfyless.com\/index.php\/wp-json\/wp\/v2\/comments?post=96"}],"version-history":[{"count":2,"href":"https:\/\/www.icfyless.com\/index.php\/wp-json\/wp\/v2\/posts\/96\/revisions"}],"predecessor-version":[{"id":103,"href":"https:\/\/www.icfyless.com\/index.php\/wp-json\/wp\/v2\/posts\/96\/revisions\/103"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.icfyless.com\/index.php\/wp-json\/wp\/v2\/media\/97"}],"wp:attachment":[{"href":"https:\/\/www.icfyless.com\/index.php\/wp-json\/wp\/v2\/media?parent=96"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.icfyless.com\/index.php\/wp-json\/wp\/v2\/categories?post=96"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.icfyless.com\/index.php\/wp-json\/wp\/v2\/tags?post=96"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}