Skip to content

Instantly share code, notes, and snippets.

View sunxhy's full-sized avatar

Persephone Martinez sunxhy

View GitHub Profile
@sunxhy
sunxhy / js-for.js
Last active June 5, 2021 04:26
JS中的各种遍历方法
1、for
for(let i=0;i<len;i++){
//do something
}
2、forEach
@sunxhy
sunxhy / vuebj.txt
Created April 8, 2021 07:21
vue笔记
储存数据
localStorage.setItem('accessToken', 'Bearer ' + response.data.result.accessToken)
取出数据
localStorage.getItem('accessToken')
删除储存数据
localStorage.removeItem('accessToken')
更改数据
@sunxhy
sunxhy / smzq.txt
Last active March 30, 2021 02:47
微信小程序:生命周期
下面从三个方面来介绍小程序的生命周期:
(1)应用生命周期
(2)页面生命周期
(3)应用及页面生命周期的触发顺序
1.应用生命周期
App() 必须在 app.js 中调用,必须调用且只能调用一次,app.js中定义了一些应用的生命周期函数
(1)onLaunch: 初始化小程序时触发,全局只触发一次
(2)onShow: 小程序初始化完成或用户从后台切换到前台显示时触发
(3)onHide: 用户从前台切换到后台隐藏时触发
@sunxhy
sunxhy / wx.txt
Last active March 30, 2021 03:14
小程序 笔记
微信小程序接口工具包,无需服务器,无需开发后台,开箱即用,轻松开发小程序
https://github.com/gooking/apifm-wxapi
------------------------------------------------
App()
注册一个小程序
在其他子页面如何使用呢?
var app = getApp();
console.log(app.globalData.helloFromApp); // 调用全局变量
app.test(); // 调用全局方法
@sunxhy
sunxhy / resize-images.html
Last active April 25, 2020 14:17
[图片的宽和高分别等比例缩放]
//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%;
@sunxhy
sunxhy / getTimeAll.js
Created April 22, 2020 08:48
[获取2个时间段的所有日期数组]
//获取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;
@sunxhy
sunxhy / a.js
Last active April 22, 2020 05:09
[js 数组与字符串的相互转换] #转换
//一、数组转字符串
//需要将数组元素用某个字符连接成字符串,示例代码如下:
var a, b,c;
a = new Array(a,b,c,d,e);
b = a.join('-'); //a-b-c-d-e 使用-拼接数组元素
c = a.join(''); //abcde
//二、字符串转数组
//实现方法为将字符串按某个字符切割成若干个字符串,并以数组形式返回,示例代码如下:
@sunxhy
sunxhy / arr.js
Last active April 22, 2020 05:09
[js 字符串数组转为数字数组 (互换)] #转换
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]
@sunxhy
sunxhy / randArr.js
Last active April 22, 2020 05:15
[打乱数组顺序] #数组
// 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;
@sunxhy
sunxhy / catlist.html
Last active April 21, 2020 05:41
[xyhcms获取自己顶级栏目] #xyhcms
<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>