微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

背景图片网页组件

如何解决背景图片网页组件

您好,我已经开始研究Web组件,我正在尝试创建一种“警告框”,该警告框会在显示您是否成功处理了http请求的http请求之后弹出,所以我做了此基本设置

const template = document.createElement('template')
template.innerHTML =   `
  <style>
  .wrap-Boxo{
    display:flex;
    width:100vw;
    height:100vh;
    position:absolute;
    alig-items:center;
    justify-content:center;
  }
    .icon{
      background-size:cover;
      width:50px;
      height:50px;
    }
  </style>
  <div class="wrap-Boxo">
    <div class="Boxo">

    <div class="do1"></div>
    <div class="do2"></div>
    <div class="icon"></div>
    <div class="message">
      
    </div>

    </div>
  </div>
 `;

 class Boxo extends HTMLElement{
   constructor(){
     super();
     
    this.attachShadow({mode:'open'})
    this.shadowRoot.appendChild(template.content.cloneNode(true));
          this.shadowRoot.querySelector('.icon').backgroundImage = "url("+this.getAttribute('iconimg')+"";

   
   }
 }
 window.customElements.define('bo-xo',Boxo);

  <bo-xo iconimg ="https://helpx.adobe.com/content/dam/help/en/stock/how-to/visual-reverse-image-search/jcr_content/main-pars/image/visual-reverse-image-search-v2_intro.jpg"></bo-xo>

但是我没有在CSS规则中得到图像,我在做什么错了?

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。