iframe报错:Permission was denied f

2026-01-26  本文已影响0人  Mr老朝

1、iframe嵌入地址后,访问报错:Permission was denied for this request to access theunknownaddress space.

处理方案:加上allow="local-network-access",如:

<template>
  <iframe
    class="myiframe"
    frameborder="no"
    border="0"
    marginwidth="0"
    marginheight="0"
    allowfullscreen
    :src="url"
    allow="local-network-access"
  ></iframe>
</template>

<style lang="scss" scoped>
  .myiframe {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    min-width: 100vw;
    max-width: 100vw;
    height: 100vh;
    min-height: 100vh;
    max-height: 100vh;
    border: none;
    overflow: hidden;
    margin: 0;
    padding: 0;
  }
</style>

2、本地运行iframe报错:The request client is not a secure context and the resource is in more-private address space `local`

处理方案,给devServer打开https,如:

    devServer: {
        https: true,
        ...
上一篇 下一篇

猜你喜欢

热点阅读