代码拉取完成,页面将自动刷新
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<script src="./dist/idnex.js"></script>
<!-- 测试单例模式 -->
</head>
<body id="body-dom">
<button id="createAlert">创建弹窗</button>
<button id="removeAlert">移除弹窗</button>
</body>
<script src="./dist/SingletonPattern-class.js"></script>
<script lang="ts">
const singleton1 = Singleton.getInstance({ height: '200px', width: '200px', html: 'bbbb', style: { color: 'pink' } })
const singleton2 = Singleton.getInstance({ height: '200px', width: '200px', html: 'aaaa', style: { color: 'black' } })
console.log('singleton1', singleton1);
console.log('singleton2', singleton2);
// const createAlertBtn = document.getElementById('createAlert')
// const removeAlertBtn = document.getElementById('removeAlert')
// const bodyDom = document.getElementById('body-dom')
// let div
// createAlertBtn.onclick = function () {
// // 调用了两次方法,但是只创建了一个实例
// div = singletonCreateAlertMessage({ height: '200px', width: '200px', html: '123123', style: { color: 'red' } })
// const div1 = singletonCreateAlertMessage({ height: '200px', width: '200px', html: 'aaaaa', style: { color: 'green' } })
// console.log('div === div1', div === div1);
// bodyDom.appendChild(div)
// bodyDom.appendChild(div1)
// }
// removeAlertBtn.onclick = function () {
// bodyDom.removeChild(div)
// }
</script>
</html>
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。