简体   繁体   English

类型元素上不存在属性attachshadow

[英]property attachshadow does not exist on type element

I created a new visual studio project with type Typescript with html application , I am trying to create a shadow dom but there is an error. 我创建了一个新的Visual Studio项目,类型为Typescript和html application,我试图创建一个影子dom,但是出现错误。

class Append{
    element: HTMLElement;

    constructor(element: HTMLElement) {
        this.element = element;
    }


window.onload = () => {
    var el = document.getElementById('content');
    let shadow = el.attachShadow({mode: 'open'});
}

property attachshadow does not exist on type element 类型元素上不存在属性attachshadow

Not all elements can accept a Shadow DOM. 并非所有元素都可以接受Shadow DOM。

The list of authorized HTML elements is defined in the attachShadow() definition in the Shadow DOM v1 specification: 在Shadow DOM v1规范的attachShadow()定义中定义了授权HTML元素的列表:

valid custom element name, <article> , <aside> , <blockquote> , <body> , <div> , <footer> , <h1> , <h2> , <h3> , <h4> , <h5> , <h6> , <header> , <main> , <nav> , <p> , <section> or <span> 有效的自定义元素名称<article><aside><blockquote><body><div><footer><h1><h2><h3><h4><h5><h6><header><main><nav><p><section><span>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM