您的位置:首页 > 博客中心 > 前端开发 >

【学习记录】微信小程序:前端开发实战

时间:2022-09-07 11:14

目录

页面创建

  1. 路由页面 route

小程序打开后第一个进入的页面

  1. 登录页面 enroll
  2. 注册页面 register
  3. 底部菜单栏 bottom_menu
  4. 首页页面 home
  5. 社区页面 community
  6. 发布任务页面 publish
  7. 任务页面 task
  8. 我的页面 mine
技术图片
Page({
  data: {
    userInfo: {},
    hasUserInfo: false,
    canIUseGetUserProfile: false,
  },
  onLoad() {
    if (wx.getUserProfile) {
      this.setData({
        canIUseGetUserProfile: true
      })
    }
  },
  getUserProfile(e) {
    // 推荐使用wx.getUserProfile获取用户信息,开发者每次通过该接口获取用户个人信息均需用户确认
    // 开发者妥善保管用户快速填写的头像昵称,避免重复弹窗
    wx.getUserProfile({
      desc: ‘用于完善会员资料‘, // 声明获取用户个人信息后的用途,后续会展示在弹窗中,请谨慎填写
      success: (res) => {
        this.setData({
          userInfo: res.userInfo,
          hasUserInfo: true
        })
      }
    })
  },
})

?

关闭当前页面,跳转到应用内的某个页面。但是不允许跳转到 tabbar 页面。

?

显示 loading 提示框。需主动调用 wx.hideLoading 才能关闭提示框

?

隐藏 loading 提示框

在app.js中的globalData一般是用来存储全局变量的。

globalData: {
    user: {}, //后台返回用户全部信息
    userInfo: {}, //微信获取用户信息
}

本类排行

今日推荐

热门手游