标签: 小程序怎么调用不同页面的函数

  • 小程序怎么调用不同页面的函数_读书小站

    本文收集自网络,侵删!

    小程序调用不同页面函数的案例:

    函数写在对应的js文件,代码如下:

    function fORMatTime(date) {

    var year = date.getFullYear()

    var month = date.getMonth() + 1

    var day = date.getDate()

    var hour = date.getHours()

    var minute = date.getMinutes()

    var second = date.getSeconds()

    return [year, month, day].map(formatNumber).join('/') + ' ' + [hour, minute, second].map(formatNumber).join(':')

    }

    function formatNumber(n) {

    n = n.toString()

    return n[1] ? n : '0' + n

    }

    module.exports = {

    formatTime: formatTime,

    }

    在其他页面中调用的代码如下:

    collegeChoiceTap:function(e){

    if(this.data.index !==e.detail.value){

    console.log(getApp().globalData.college_change) 。

    getApp().get_a_test()

    this.setData({

    index: e.detail.value

    })

    }

    }