const $ = () => document.querySelector.call(this, arguments);
const $$ = () => document.querySelectorAll.call(this, arguments);
HTMLElement.prototype.on = (a, b, c) => this.addEventListener(a, b, c);
HTMLElement.prototype.off = (a, b) => this.removeEventListener(a, b);
HTMLElement.prototype.$ = (s) => this.querySelector(s);
HTMLElement.prototype.$ = (s) => this.querySelectorAll(s);
Previously:
const navbar = document.querySelector("nav")
Now:
$("nav")
标签:document,const,querySelector,DOM,Javascript,alias,HTMLElement,prototype From: https://www.cnblogs.com/Answer1215/p/17564088.html