wepy 文件结构/组件开发

脚手架生成的app.wpy文件是小程序入口

<style lang="less">
.container {
height: 100%;
display: flex;
flex-direction: column;
align-items: center;
justify-content: space-between;
box-sizing: border-box;
}
</style>

<script>
import wepy from 'wepy'
import 'wepy-async-function'


export default class extends wepy.app {
config = {
pages: [
// 'pages/index', 对应路由
'pages/home',
'pages/activites',
'pages/features',
'pages/mine'
],
window: {
backgroundTextStyle: 'light',   窗口
navigationBarBackgroundColor: '#fff',
navigationBarTitleText: 'MyChat',
navigationBarTextStyle: 'black'
},
tabBar: {
list: [{
pagePath: "pages/home",
iconPath:'image/shouye_0.png', 底部导航
selectedIconPath:'image/shouye_1.png',
text: "首页"
}, {
pagePath: "pages/activites",
iconPath:'image/kecheng_0.png',
selectedIconPath:'image/kecheng_1.png',
text: "课程"
}, {
pagePath: "pages/features",
iconPath:'image/shizi_0.png',
selectedIconPath:'image/shizi_1.png',
text: "师资"
}, {
pagePath: "pages/mine",
iconPath:'image/wode_0.png',
selectedIconPath:'image/wode_1.png',
text: "我的"
}]
},
}

globalData = { 全局变量
userInfo: null
}

constructor () {
super()
this.use('requestfix')
}

onLaunch() { web
this.testAsync()
}

sleep (s) {
return new Promise((resolve, reject) => {
setTimeout(() => {
resolve('promise resolved')
}, s * 1000)
})
}

async testAsync () {
const data = await this.sleep(3)
console.log(data)
}

getUserInfo(cb) {
const that = this
if (this.globalData.userInfo) {
return this.globalData.userInfo
}
wepy.getUserInfo({
success (res) {
that.globalData.userInfo = res.userInfo
cb && cb(res.userInfo)
}
})
}
}
</script>

转载于:https://www.cnblogs.com/zfyan-1992/p/9799529.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值