Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
4.2k views
in Technique[技术] by (71.8m points)

Vue 项目中, 使用iframe 引用本地html要如何实现?

目前网上的方法都是将html放在public或者static目录中.

能不能让html放在任何位置也能成功加载


本问题又名:

  • 在Vue中使用iframe相对路径引入本地html页面,报错404
  • Vue使用iframe加载本地的html文件
  • Vue利用iframe框架加载本地html文件页面不显示
  • Load .html file in the VUE
  • Load static HTML files in Vue
  • Load local HTML files in Vue

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

使用 html-loader 就行, 但是 html-loaderhtml-webpack-plugin 冲突 , 自己看着来吧 ;


目前我是将静态资源放在 public 目录下, 例如:

<template>
  <div class="receipt-qrcode-agreement">
    <iframe ref="iframe" :src="`/html/payment-code-agreement/${language}/index.html`" frameborder="0" />
  </div>
</template>

<script>
import { get as getLanguage } from '@/utils/language.js'
export default {
  data() {
    return {
      language: ''
    }
  },
  created() {
    this.language = getLanguage()
  },
}
</script>

<style lang="scss" scoped src="./index.scss"></style>

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...