//index.js //获取应用实例 const app = getApp() import { lookInit } from '../../component/look/look'; import { myInit } from '../../component/mys/mys'; import httpRequestApi from '../../utils/APIRequest'; Page({ data: { tab:[ { name: '看', templates: 'look', img: '../../static/image/look1.png', selectimg: '../../static/image/look2.png' }, { name: '搜', templates: 'search', img: '../../static/image/sou1.png', selectimg: '../../static/image/sou2.png' }, { name: '我的', templates: 'mys', img: '../../static/image/my1.png', selectimg: '../../static/image/my2.png' } ], ind: 0, templates: 'look', }, //tab点击 switcher: function({currentTarget}) { let ind = currentTarget.dataset.ind; let templates = this.data.tab[ind].templates; //console.log(this.data[ind]) this.setData({ ind, templates }) }, onLoad: function () { lookInit(this); myInit(this); }, })