//index.js import dayjs from '../../utils/dayjs/index.js' import relativeTime from '../../utils/dayjs/relativeTime.js' dayjs.extend(relativeTime); import { HomeModel} from '../../models/home.js' let homeModel = new HomeModel() Page({ data: { list: [ { id: '1', title: '啦啦啦量阿拉蕾阿拉啦', showTop: true, time: '刚刚' }, { id: '2', title: '一条大河,向东流', showTop: false, time: '1分钟前' }, { id: '3', title: '啦啦啦量阿拉蕾阿拉啦', showTop: false, time: '1小时前' }, ] }, onLoad: function () { console.log(dayjs().toNow()) console.log(dayjs().from(dayjs('1990'))) this.fetchHomeList() }, // 获取首页列表 fetchHomeList () { homeModel.getHomeList(res => { console.log('啦啦啦') console.log(res) }) }, tapSwiperItem (e) { console.log(e.detail) this.gotoArticePage(e.detail.id) }, tapFocusItem (e) { console.log(e.detail) this.gotoArticePage(e.detail.id) }, clickListItem (e) { console.log(e.detail) this.gotoArticePage(e.detail.id) // wx.redirectTo({ // url: '/pages/register/index', // }) }, gotoArticePage (id) { wx.navigateTo({ url: `/pages/article/index?id=${id}`, }) } })