随笔分类 -  JavaScript

摘要:getSystemInfoSync 获取用户设备的相关信息 示例代码: 使用位置:在 JS文件的任意函数中使用 const res = wx.getSystemInfoSync(); console.log(res); console.log(res.model); // 设备机型 console. 阅读全文
posted @ 2019-12-23 18:16 GetcharZp 阅读(1912) 评论(0) 推荐(0)
摘要:base64ToArrayBuffer 将 base64 的字符串转化为 ArrayBuffer 对象 示例代码: 使用位置:在 JS文件的任意函数中使用 const base64 = 'CxYh'; console.log(wx.base64ToArrayBuffer(base64)) 阅读全文
posted @ 2019-12-23 18:10 GetcharZp 阅读(2882) 评论(0) 推荐(0)
摘要:// 获取浏览器 宽高 var width = window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth var height = window.innerHeight || docu 阅读全文
posted @ 2019-12-19 18:17 GetcharZp 阅读(243) 评论(0) 推荐(0)
摘要:// 1、数组拼接 concat() var a = [1, 2]; var b = [3, 4]; console.log(a.concat(b)); // [1, 2, 3, 4] // 2、数组翻转 reverse() var a = [1, 2, 3]; console.log(a.reve 阅读全文
posted @ 2019-12-19 11:52 GetcharZp 阅读(256) 评论(0) 推荐(0)
摘要:// 函数声明方法一 function f (a, b) { return a + b; } // 函数调用 console.log(f(1, 4)); // 5 // 函数声明方法二 var num = function(a, b) { return a + b; } console.log(nu 阅读全文
posted @ 2019-12-19 11:05 GetcharZp 阅读(145) 评论(0) 推荐(0)
摘要:// 1、for循环 for (var i = 0; i <= 10; ++ i) { console.log(i); } // 2、while循环 var i = 0; while (i <= 10) { console.log(i); ++ i; } 阅读全文
posted @ 2019-12-19 10:45 GetcharZp 阅读(233) 评论(0) 推荐(0)
摘要:// 1、if...else if (true) { console.log("TRUE1"); } else { console.log("TRUE2"); } // 2、if...else if...else if (true) { console.log("TRUE1"); } else if 阅读全文
posted @ 2019-12-19 10:41 GetcharZp 阅读(371) 评论(0) 推荐(0)
摘要:// 1、Boolean() console.log(Boolean(123)); // true console.log(Boolean(undefined)); // false console.log(Boolean("false")); // true // 2、流程控制自动转化 var c 阅读全文
posted @ 2019-12-19 09:32 GetcharZp 阅读(340) 评论(0) 推荐(0)
摘要:// 1、Number() var num1 = Number(true); console.log(num1); // 1 var num2 = Number(" ") console.log(num2); // 0 // 2、parseInt() var num1 = parseInt("12. 阅读全文
posted @ 2019-12-19 09:28 GetcharZp 阅读(4107) 评论(0) 推荐(0)
摘要:// 1、 toString() var num = 8; var numString = num.toString(); console.log(numString); var result = true; var resultString = result.toString(); console 阅读全文
posted @ 2019-12-19 09:20 GetcharZp 阅读(8061) 评论(0) 推荐(0)
摘要:wx.canIUse(); 微信文档中定义在API中,可以理解为一个函数。 返回值: true 或者 false 示例: // 在JS文件的函数中进行使用 console.log(wx.canIUse('console.log')); // 输出:true 阅读全文
posted @ 2019-12-16 10:33 GetcharZp 阅读(1507) 评论(0) 推荐(0)
摘要:wxml: data-参数名="值" bindtap="函数名" <view class="buy-button {{cap_select == 100 ? 'zp-active': ''}}" data-cap="100" bindtap="choose_cap"> <text>100ML \n 阅读全文
posted @ 2019-12-12 09:56 GetcharZp 阅读(4842) 评论(0) 推荐(0)
摘要:不转换成JSON 会报错 Unexpected identifier 方法: JSON.stringify(对象) 阅读全文
posted @ 2019-12-06 16:22 GetcharZp 阅读(603) 评论(0) 推荐(0)
摘要:修改 app.json 文件即可 "tabBar": { "selectedColor": "#1296db", "list": [ { "pagePath": "pages/index/index", "text": "首页" }, { "pagePath": "pages/setting/set 阅读全文
posted @ 2019-12-04 17:32 GetcharZp 阅读(520) 评论(0) 推荐(0)
摘要:jquery 中 html与text函数的区别 共同点:它们都能讲函数中的参数渲染到页面中; 异同点: text() 只是简单的讲参数的内容写入到页面中; html() 会根据参数的值,判断是否字体符号之类的,并进行对应的html类型的解析 阅读全文
posted @ 2019-12-03 22:07 GetcharZp 阅读(304) 评论(0) 推荐(0)
摘要:JQuery 时间戳转时间 var date = new Date(stocks[i]['create_time'] * 1000); var y = date.getFullYear(); var m = "00" + (date.getMonth() + 1).toString(); m = m 阅读全文
posted @ 2019-11-28 16:51 GetcharZp 阅读(160) 评论(0) 推荐(0)
摘要:jquery 判断是否为空 if(my_val == null || my_val == undefined || my_val==""){ console.log("我为空"); } 阅读全文
posted @ 2019-11-26 14:21 GetcharZp 阅读(1997) 评论(0) 推荐(0)
摘要:jquery 通过 toFixed 保留两位小数 <script> var num = 12.21654; console.log(num.toFixed(2)) </script> 阅读全文
posted @ 2019-11-21 16:42 GetcharZp 阅读(5673) 评论(0) 推荐(0)
摘要:使用 layUI做一些简单的表单验证 <form method="post" class="layui-form" > <input name="username" placeholder="用户名" type="text" lay-verify="required" class="layui-in 阅读全文
posted @ 2019-11-16 00:03 GetcharZp 阅读(323) 评论(0) 推荐(0)
摘要:jquery 向页面追加HTML append 函数 例子: <div id="append-test"></div> <script type="text/javascript"> $("#append-test").append("<span>Append</span>"); </script> 阅读全文
posted @ 2019-11-15 15:12 GetcharZp 阅读(4049) 评论(0) 推荐(0)