加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
factory.html 1.18 KB
一键复制 编辑 原始数据 按行查看 历史
doudoucode 提交于 2020-06-29 17:38 . doudou init commit
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
.box{
width: 100px;
height: 100px;
border-radius: 100%;
background: red;
color: rgb(13, 45, 223);
line-height: 100px;
text-align: center;
font-weight: 700;
}
</style>
</head>
<body>
<div class="box">&lt抖抖/&gt</div>
<script>
class DoudouLogo extends HTMLElement{
connectedCallback(){
this.render();
}
render(){
this.style.background = "blue";
this.style.width = "100px"
this.style.height = "100px"
this.innerHTML = "hello";
this.style.display = "block";
}
sayhello(){
alert("hello");
}
}
customElements.define("doudou-logo",DoudouLogo);
const box = document.createElement("doudou-logo");
box.sayhello();
document.body.append(box);
</script>
</body>
</html>
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化