相思资源网 Design By www.200059.com

一、调取参数

直接调取当前js中的方法,

调取参数that.bindViewTap();

二、跳转页面

navigateTo: function () {
wx.navigateTo({ url: '../page4/page4' });
},
 
 
全局变量使用方法
a.js
var app = getApp()
Page({
data: {
hex1: [],
})}
//设置全局变量
if (hex1 != null) {
app.globalData.hex1 = hex1;
}
 
b.js
接收全局变量
var app = getApp()
Page({
 data:{
  hex1:[]
 },
 
onLoad:function(options){
   this.setData({
   hex1:getApp().globalData.hex1
  });
 },
 
})

三、获取事件的方法:

获取事件的方法:
bindViewTap1: function (e) {
console.log('事件event',e)
}
 
监听input方法
a.wxml页面
<input type="number" maxlength="2" placeholder="小于100分钟" placeholder-class="psection" bindinput="listenerTimeInput" />
 
a.js页面
//监听input框输入
listenerTimeInput: function (e) {
this.data.time = e.detail.value;
console.log('哒哒this.data.time', this.data.time)
},
 
获取当前时间戳
var timestamp = Date.parse(new Date());
timestamp = timestamp / 1000;
console.log("当前时间戳为:" + timestamp);
 
时间转换为秒
var stime = '';
var format = '';
stime = time * 60;
console.log('秒', stime);
 
转换为时间
Date.prototype.format = function (format) {
var date = {
"M+": this.getMonth() +1,
"d+": this.getDate(),
"h+": this.getHours(),
"m+": this.getMinutes(),
"s+": this.getSeconds(),
"q+": Math.floor((this.getMonth() +3) /3),
"S+": this.getMilliseconds()
};
if (/(y+)/i.test(format)) {
format = format.replace(RegExp.$1, (this.getFullYear() +'').substr(4 - RegExp.$1.length));
}
for (var kin date) {
if (new RegExp("(" + k +")").test(format)) {
format = format.replace(RegExp.$1, RegExp.$1.length == 1
"00" + date[k]).substr(("" + date[k]).length));
}
}
return format;
}
var oktime = '';
oktime = newDate.format('yyyy-MM-dd h:m:s');
 
//获取当前时间
var date = new Date();
var seperator1 = "-";
var seperator2 = ":";
var month = date.getMonth() + 1;
console.log('大大', month);
var strDate = date.getDate();
if (month >= 1 && month <= 9) {
month = "0" + month;
}
console.log('大大', month);
if (strDate >= 0 && strDate <= 9) {
strDate = "0" + strDate;
}
var currentdate = date.getFullYear() + seperator1 + month + seperator1 + strDate + " " + date.getHours() + seperator2 + date.getMinutes() + seperator2 + date.getSeconds();
console.log('当前时间', currentdate);
console.log('年', date.getFullYear());
console.log('月', month);
console.log('日', date.getDate());
console.log('时', date.getHours())
console.log('分', date.getMinutes())
 
 
转为串
oktime = oktime.toString();
 
提取数值
var oktime = oktime.replace(/[^0-9]/ig, "");
console.log('oktime', oktime);
 
获取年 月 日 时 分 秒
var year1 = '';var month1 ='';var date1 ='';var hours1 ='';var min1 ='';
year1 = oktime.substring(2, 4);
console.log('year1', year1);
month1 = oktime.substring(4, 6);
console.log('month1', month1);
date1 = oktime.substring(6, 8);
console.log('date1', date1);
hours1 = oktime.substring(8, 10);
console.log('hours1', hours1);
min1 = oktime.substring(10, 12);
console.log('min1', min1);
 
转换为16进制
  
var zhen4000 = parseInt(zhen400);
  
console.log('飞zhen4000', zhen4000)
    
zhen4000 = zhen4000.toString(16);
 
console.log('@@@@@zhen4000', zhen4000);
 
将值由16进制转10进制
zhen1 = parseInt(zhen001, 16);
 
// 进行异或运算
//注:我使用过16进制的异或运算,没成功,最后使用了比较复杂的方法,由十六进制转化为十进制异或运算,将得到的值在转为十六进制
zhen9 = zhen1 ^ zhen2

四、点击事件url传值

点击事件url传值
wx.redirectTo({
url: '../page1/page1"bindViewTap1"值触发到到js里面的bindViewTap1:function方法
.wxml
<navigatorbindtap="bindViewTap1"id='time1'url="../page5/page5"hover-class="navigator-hover">
 
.js
bindViewTap1: function (e) {
//hex1
var id = e.currentTarget.id;
console.log('坎坎坷坷扩id',id);
}
 
设置跳出循环
//跳出循环,只运行一次
在data()里面添加
flag : '',
在你使用的方法里面加
var flag = true;
if (flag) {
that.bindViewTap3();
that.bindViewTap2();
flag = false;
}
 
 
函数间传值
//设置全局data
 data{rtime:''}
 
btn1: function(e){
 this.setData({
   rtime : time
  })
}
 
btn2:funciton(e){
 console.log('###@@@@@#',this.data.rtime)
} 

以上所述是小编给大家介绍的微信小程序的不同函数调用的几种方法详解整合,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对网站的支持!

标签:
微信小程序函数调用,微信小程序函数调用方法

相思资源网 Design By www.200059.com
广告合作:本站广告合作请联系QQ:858582 申请时备注:广告合作(否则不回)
免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件! 如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
相思资源网 Design By www.200059.com

评论“详解微信小程序的不同函数调用的几种方法”

暂无详解微信小程序的不同函数调用的几种方法的评论...

RTX 5090要首发 性能要翻倍!三星展示GDDR7显存

三星在GTC上展示了专为下一代游戏GPU设计的GDDR7内存。

首次推出的GDDR7内存模块密度为16GB,每个模块容量为2GB。其速度预设为32 Gbps(PAM3),但也可以降至28 Gbps,以提高产量和初始阶段的整体性能和成本效益。

据三星表示,GDDR7内存的能效将提高20%,同时工作电压仅为1.1V,低于标准的1.2V。通过采用更新的封装材料和优化的电路设计,使得在高速运行时的发热量降低,GDDR7的热阻比GDDR6降低了70%。