标签:type bsp code func cti use script 全局变量 fun
class Header { constructor() { const elem = document.createElement(‘div‘); elem.innerText = ‘This is Header‘; document.body.appendChild(elem); } } class Content { constructor() { const elem = document.createElement(‘div‘); elem.innerText = ‘This is Content‘; document.body.appendChild(elem); } } class Footer { constructor() { const elem = document.createElement(‘div‘); elem.innerText = ‘This is Footer‘; document.body.appendChild(elem); } } class Page{ constructor() { new Header(); new Content(); new Footer(); } }
这些代码编译完是这样的
"use strict"; var Header = /** @class */ (function () { function Header() { var elem = document.createElement(‘div‘); elem.innerText = ‘This is Header‘; document.body.appendChild(elem); } return Header; }()); var Content = /** @class */ (function () { function Content() { var elem = document.createElement(‘div‘); elem.innerText = ‘This is Content‘; document.body.appendChild(elem); } return Content; }()); var Footer = /** @class */ (function () { function Footer() { var elem = document.createElement(‘div‘); elem.innerText = ‘This is Footer‘; document.body.appendChild(elem); } return Footer; }()); var Page = /** @class */ (function () { function Page() { new Header(); new Content(); new Footer(); } return Page; }());
namespace Home{ class Header { constructor() { const elem = document.createElement(‘div‘); elem.innerText = ‘This is Header‘; document.body.appendChild(elem); } } class Content { constructor() { const elem = document.createElement(‘div‘); elem.innerText = ‘This is Content‘; document.body.appendChild(elem); } } class Footer { constructor() { const elem = document.createElement(‘div‘); elem.innerText = ‘This is Footer‘; document.body.appendChild(elem); } } export class Page{ constructor() { new Header(); new Content(); new Footer(); } } }
<script> new Home.Page(); </script>
标签:type bsp code func cti use script 全局变量 fun
原文地址:https://www.cnblogs.com/wzndkj/p/13171310.html