页面加载内容

小程序加载内容

/**
   * 页面的初始数据
   */
  data: {
    
    
    newsData:[]
  },
/**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    
    
    wx.request({
    
    
      url: 'http://jsonplaceholder.typicode.com/todos',
      success:res=>{
    
    
        this.setData({
    
    
          newsData:res.data
        })
      }
    })
  },
 <view class="newsItem" wx:for="{
     
     {newsData}}" wx:key="id">
    <text>{
   
   {item.title}}</text>
    <text>{
   
   {item.completed}}</text>
  </view>

路由跳转

  • wx.switchTap:跳转到 tabBar 页面,并关闭其他所有非 tabBar 页面*
  • wx.navigateTo:保留当前页面,跳转到应用内的某个页面。但是不能跳到 tabbar 页面。使用 wx.navigateBack 可以返回到原页面。小程序中页面栈最多十层。*
  • wx.redirectTo:关闭当前页面,跳转到应用内的某个页面。但是不允许跳转到 tabbar 页面*
  • wx.reLaunch:关闭所有页面,打开到应用内的某个页面*

事件绑定

  • bindtap 和 catchtap:catch 会阻止冒泡
  •      dataset 带参数
         事件中布尔值
    

猜你喜欢

转载自blog.csdn.net/weixin_54645137/article/details/113358827