会员可以在此提问,百战程序员老师有问必答
对大家有帮助的问答会被标记为“推荐”
看完课程过来浏览一下别人提的问题,会帮你学得更全面
截止目前,同学们一共提了 132647个问题
WEB前端全系列/第十四阶段:微信小程序/实战_百战商城 16楼
WEB前端全系列/第十四阶段:微信小程序/实战_百战商城 17楼
WEB前端全系列/第十四阶段:微信小程序/小程序WXML语法 21楼
WEB前端全系列/第十四阶段:微信小程序/小程序API 22楼
WEB前端全系列/第十四阶段:微信小程序/小程序组件 23楼
WEB前端全系列/第十四阶段:微信小程序/小程序框架 24楼
WEB前端全系列/第十四阶段:微信小程序/小程序框架 25楼
WEB前端全系列/第十四阶段:微信小程序/实战_百战商城 27楼

微信图片_20221021161638.png

// pages/musicList/musicList.js
const {request}=require('../../utils/request')
Page({

    /**
     * 页面的初始数据
     */
    data: {
      songs:[],
      limit:20,
      offset:1,
      search:''
    },

    /**
     * 生命周期函数--监听页面加载
     */
    onLoad(options) {
  console.log(options);
  this.setData({
      search:options.search
  })
  this.http(this.data.search,this.data.limit,this.data.offset)
    },
http(keywords,limit,offset){
    request("http://iwenwiki.com:3000/search",{keywords,limit,offset},'GET').then(res=>{
        console.log(res);
        if(res.data.result.songs){
            this.setData({
                songs:this.data.songs.concat(res.data.result.songs)
            })
        }else{
            wx.showToast({
              title: '暂无数据',
            })
        }
    }).catch(err=>{
        wx.showToast({
          title: '请求出错了',
        })
        console.log(err);
    })
},
    /**
     * 生命周期函数--监听页面初次渲染完成
     */
    onReady() {

    },

    /**
     * 生命周期函数--监听页面显示
     */
    onShow() {

    },

    /**
     * 生命周期函数--监听页面隐藏
     */
    onHide() {

    },

    /**
     * 生命周期函数--监听页面卸载
     */
    onUnload() {

    },

    /**
     * 页面相关事件处理函数--监听用户下拉动作
     */
    onPullDownRefresh() {
         this.setData({
             offset:1,
             songs:[]
         })
         this.http(this.data.search,this.data.limit,this.data.offset)
    },
    //跳转到播放器页面
    goToPlayer(e){
        console.log(e);
        
        console.log(e.currentTarget.dataset);
        console.log(e.currentTarget.dataset.id);
        wx.navigateTo({
          url: '../player/player?id=?'+e.currentTarget.dataset.id
        })
    },

    /**
     * 页面上拉触底事件的处理函数
     */
    onReachBottom() {
        this.setData({
            offset: this.data.offset += 20
           })
          this.http(this.data.search, this.data.limit, this.data.offset)
         
    },

    /**
     * 用户点击右上角分享
     */
    onShareAppMessage() {

    }
})


console.log(e.currentTarget.dataset)

老师 为啥我正常  

 console.log(e.currentTarget.dataset.id);

underfind呢?

WEB前端全系列/第十四阶段:微信小程序/小程序API 28楼
WEB前端全系列/第十四阶段:微信小程序/实战_百战商城 29楼

课程分类

百战程序员微信公众号

百战程序员微信小程序

©2014-2025百战汇智(北京)科技有限公司 All Rights Reserved 北京亦庄经济开发区科创十四街 赛蒂国际工业园
网站维护:百战汇智(北京)科技有限公司
京公网安备 11011402011233号    京ICP备18060230号-3    营业执照    经营许可证:京B2-20212637