Welcome toVigges Developer Community-Open, Learning,Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
3.7k 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 Answer

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>

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to Vigges Developer Community for programmer and developer-Open, Learning and Share
...