826327700 / vue-photo-preview

基于photoswipe的vue图片预览组件
471 stars 123 forks source link

增加 appendToEl #92

Open Lin-Kangjing opened 1 year ago

Lin-Kangjing commented 1 year ago

Hi! 👋

Firstly, thanks for your work on this project! 🙂

Today I used patch-package to patch vue-photo-preview@1.1.3 for the project I'm working on.

Here is the diff that solved my problem:

diff --git a/node_modules/vue-photo-preview/src/lib/index.js b/node_modules/vue-photo-preview/src/lib/index.js
index 67ec150..447ce10 100644
--- a/node_modules/vue-photo-preview/src/lib/index.js
+++ b/node_modules/vue-photo-preview/src/lib/index.js
@@ -8,7 +8,12 @@ var vuePhotoPreview ={
         var opts=opts||{}
         if (!$preview) {
             $preview = new Preview({el: document.createElement('div')})
-           document.body.appendChild($preview.$el)
+                       if(opts.appendToEl){
+                           opts.appendToEl.appendChild($preview.$el)
+                       }else{
+                           document.body.appendChild($preview.$el)
+                       }
+           
        }
        let eventName,eventCallback
        Vue.prototype.$preview={

This issue body was partially generated by patch-package.