class index { constructor() { this.baseUrl = "http://127.0.0.1:3000/api" this.index = 0; this.getLeftMenu(); } getLeftMenu() { var self = this; $.ajax({ type: "GET", url: this.baseUrl + "/type/leftMenu", success: function (res) { console.log(res.result); res.result.forEach((v, i) => { $(".left").append(`
  • ${v.title}

  • `); }); $(".left li").click(function () { $(this).addClass("active").siblings().removeClass("active") self.getRightMenu(res.result[$(this).index()].url); }) } }); } getRightMenu() { var self = this; $.ajax({ type: "GET", url: this.baseUrl + "/type/rightMenu", data: { url: this.leftArr[this, index].url }, success: function (res) { console.log(res.result); $(".reght").empty(); res.result.forEach(v => { $(".right").append(`
  • ${v.title}

  • `) }) } }); } } new index()