// index.js // 获取应用实例 const { $http, $utils } = getApp().globalData Page({ data: { titleIndex: '首页的标题', user_name: "", title: '你好', src: "https://www.baidu.com/img/PCtm_d9c8750bed0b3c7d089fa7d55720d6cf.png", newLis: [ { id: 1, title: '新闻1' }, { id: 2, title: '新闻2' }, { id: 3, title: '新闻3' }, { id: 4, title: '新闻4' }, ], list: [] }, onLoad() { this.getHome() }, async getHome() { let res = await $http.index.home(); console.log(res); this.setData({ list: res.list }) }, enterInfo(e) { let item = e.target.dataset.item; wx.navigateTo({ url: `/pages/info/info?id=${item.id}`, }) }, test(e){ console.log("test: ", e.detail); }, UserNameChange(e) { this.setData({ user_name: e.detail.value }) } })