(function(){
var userAgent = navigator.userAgent && navigator.userAgent.toLowerCase() || '';
if (userAgent.match(/MicroMessenger/i) != "micromessenger") {
class WxOpenLaunchWeapp extends HTMLElement
{
constructor()
{
super();
this.shadow = this.attachShadow({ mode: 'open' });
}
connectedCallback() {
var template = this.querySelector("script,template");
if (template) {
this.shadow.innerHTML = template.innerHTML;
this.removeChild(template);
}
}
}
window.customElements.define('wx-open-launch-weapp', WxOpenLaunchWeapp);
}
})();
第一次用web-component,这只是其中一种定义web-component的方式,如有问题请见谅