Commit 97b6c50a authored by 郭志伟's avatar 郭志伟

fix: 弹框组件移除pdfjs

parent 2838c5d2
......@@ -18,7 +18,7 @@
v-html="content"
></div>
<!-- iframe -->
<div class="protocol-frame-wrap" v-if="!isPdf && url && scrollRefresh">
<div class="protocol-frame-wrap" v-if="url && scrollRefresh">
<iframe class="protocol-frame" :src="url" frameborder="0" height="100%"></iframe>
</div>
<!-- slot -->
......@@ -26,9 +26,7 @@
<slot></slot>
</div>
<!-- content -->
<div class="protocol-content" v-if="isPdf && scrollRefresh && !$slots.default">
<pdf v-for="(item, index) in pdfNumPages" :key="index" :src="pdfUrl" :page="index + 1" />
</div>
<div class="protocol-content" v-if="scrollRefresh && !$slots.default"></div>
</cr-popup>
</template>
......@@ -38,7 +36,6 @@
* @param {type}
* @return:
*/
import pdf from "vue-pdf";
const CHANGE_EVENT = "input";
export default {
name: "PopupWithIframe",
......@@ -57,9 +54,6 @@ export default {
default: ""
}
},
components: {
pdf
},
watch: {
value(val) {
this.popupShow = val;
......@@ -70,41 +64,17 @@ export default {
popupShow(val) {
this.$emit(CHANGE_EVENT, val);
if (!val) {
this.pdfNumPages = null;
this.pdfUrl = null;
setTimeout(() => {
this.scrollRefresh = false;
}, 300);
}
}
},
computed: {
isPdf() {
const isPdf = this.url.indexOf("pdf") > -1;
isPdf && this.pdfTask();
return isPdf;
}
},
data() {
return {
popupShow: false,
scrollRefresh: true,
pdfUrl: "",
pdfNumPages: null
scrollRefresh: true
};
},
methods: {
pdfTask() {
this.pdfUrl = pdf.createLoadingTask(this.url);
this.pdfUrl.promise
.then(pdf => {
this.pdfNumPages = pdf.numPages;
console.error(pdf);
})
.catch(err => {
console.error(err);
});
}
}
};
</script>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment