This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1、for | |
for(let i=0;i<len;i++){ | |
//do something | |
} | |
2、forEach | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
储存数据 | |
localStorage.setItem('accessToken', 'Bearer ' + response.data.result.accessToken) | |
取出数据 | |
localStorage.getItem('accessToken') | |
删除储存数据 | |
localStorage.removeItem('accessToken') | |
更改数据 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
下面从三个方面来介绍小程序的生命周期: | |
(1)应用生命周期 | |
(2)页面生命周期 | |
(3)应用及页面生命周期的触发顺序 | |
1.应用生命周期 | |
App() 必须在 app.js 中调用,必须调用且只能调用一次,app.js中定义了一些应用的生命周期函数 | |
(1)onLaunch: 初始化小程序时触发,全局只触发一次 | |
(2)onShow: 小程序初始化完成或用户从后台切换到前台显示时触发 | |
(3)onHide: 用户从前台切换到后台隐藏时触发 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
微信小程序接口工具包,无需服务器,无需开发后台,开箱即用,轻松开发小程序 | |
https://github.com/gooking/apifm-wxapi | |
------------------------------------------------ | |
App() | |
注册一个小程序 | |
在其他子页面如何使用呢? | |
var app = getApp(); | |
console.log(app.globalData.helloFromApp); // 调用全局变量 | |
app.test(); // 调用全局方法 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//https://tugenhua0707.github.io/resize-images/index.html | |
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<title>Document</title> | |
<style> | |
.demo { | |
width: 100%; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//获取2个时间段的所有日期数组 | |
function getAll(begin, end) { // 开始日期和结束日期 | |
if (!begin || !end) { // 去除空的可能性 | |
console.log('有时间为空'); | |
return false; | |
} | |
// 在时间Date的原型中定义一个format方法 | |
Date.prototype.format = function() { | |
var s = ""; // 定义一个字符串,目的,要时间格式按照我们的要求拼接 | |
var month = this.getMonth() + 1; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//一、数组转字符串 | |
//需要将数组元素用某个字符连接成字符串,示例代码如下: | |
var a, b,c; | |
a = new Array(a,b,c,d,e); | |
b = a.join('-'); //a-b-c-d-e 使用-拼接数组元素 | |
c = a.join(''); //abcde | |
//二、字符串转数组 | |
//实现方法为将字符串按某个字符切割成若干个字符串,并以数组形式返回,示例代码如下: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var arr = [1, 2, 3, 4, 5, 6, 7, 8, 9]; | |
arr.map(String); //结果: ['1', '2', '3', '4', '5', '6', '7', '8', '9'] | |
var a = ['1', '2', '3', '4', '5', '6', '7', '8', '9'] | |
a.map(Number); //结果:[1, 2, 3, 4, 5, 6, 7, 8, 9] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// iparr 传入一个数组 | |
function randArr(iparr) { | |
var arr = iparr; | |
for (var i = 0; i < arr.length; i++) { | |
var iRand = parseInt(arr.length * Math.random()); | |
var temp = arr[i]; | |
arr[i] = arr[iRand]; | |
arr[iRand] = temp; | |
} | |
return arr; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<yang:type typeid='$cid' level='top'> | |
<yang:catlist typeid="$type['id']" type='son' flag='1'> | |
<li><a href="{$catlist.url}">{$catlist.name}</a> | |
<!-- <volist name='catlist["child"]' id='v'> | |
<a href="{$v|get_url}">- {$v.name}</a> | |
</volist> --> | |
</li> | |
</yang:catlist> | |
</yang:type> |
NewerOlder