自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(19)
  • 收藏
  • 关注

原创 promise实现红绿灯

<!DOCTYPE html><html lang="en"><head> <meta charset="UTF-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Doc

2021-04-01 14:50:47 236

原创 长轮循

长轮循:请求数据,待数据返回之后,再次请求 function http(){ let time = parseInt(Math.random()*5)*1000; return new Promise((resolve, reject) => { setTimeout(() => { resolve(time); }, time); }) } f

2021-03-30 14:08:05 113

原创 Reduce方法

arr.reduce(function(total, curValue, curIndex, arr), initvalue)//total 有initValue,仅输出一次initValue;无initValue,仅输出一次输出arr[0]1.有初始值参数var numbers = [15.5, 2.3, 1.1, 4.7];numbers.reduce((total, curValue, curIndex, arr) => { console.log(total); c

2021-03-24 11:55:43 1342

原创 for 与forEach中return用法

在函数体中for循环可以使用returnfunction dd(){ for(var i=0;i<4;i++){ return 'fanxuejing'; }console.log('aaa');}dd() //fanxuejingfunction test(){ for(var i = 0; i < 5; i++){ if(i > 3) { console.log(i) return

2021-03-23 10:01:08 902

原创 逻辑思路

请求一个方法,可能成功,可能失败。若失败,最多自动请求三次,若仍为失败,则结束。function Random() { return num = parseInt(Math.random()*10);}function Request(count = 1) { let num = Random(); if(num % 2 == 0){ console.log('失败第'+ count + '次'); count++; if(count <= 3){ Request(cou

2021-03-19 16:54:00 318

原创 解析字段

/** * @description:解析html */export default { data () { return { //解析后的对象 htmlModel:{} }; }, methods: { /** * @description:解析html * @param data:需要解析的对象 * @param args:指定解析的key */ resolver (data, ...args) { let htmlModel = O

2021-03-16 17:13:29 153

原创 watch监听对象

export default { data () { return{ model:{ email: '', password: '' } } }, watch: { model: { deep: true, // 必须,否则监听不到 immediate: true, //非必须,进入页面会执行一次 handler (newVal, oldVal){ if(!/^\w+@[a-zA-Z0-9]+(\.[a-zA-Z0-9]+)+$/.te

2021-03-15 18:10:12 193

原创 Promise

new Promise (function( resolve, reject){ setTimeout(function(){ console.log("first"); resolve(); }, 1000)}).then(function(){ new Promise(function(resolve, reject){ setTimeout(function(){ console.log("second

2021-03-12 11:15:20 68

原创 伪元素::before和::after

概念:伪元素不是真正的元素,没有HTML元素与其对应,是通过CSS样式展现的用法:是行内元素<style> p:before{content: "hello "} p:after{content: "you are handsome!"}</style><p>wonyun!</p>//等价于 <p> <span>hello </span> wonyun! <spa

2021-03-09 11:51:27 1159 1

原创 uni-app实现小程序图片下载并授权保存到本地

<template> <view class='index'> <button size='mini' @click='downloadFile'>下载</button> <toast ref='toast'></toast> <modal :show="authorizationModal" width="621rpx" custom padding="48rpx 0 0">.

2021-03-05 18:13:33 1262

原创 页面滚动到浏览器可视区域动画播放

//可视区域的高window.innerHeight || doucument.documentElement.clientHeight || document.body.clientHeight//整个网页的高(不包括边框) docunment.body.scrollHeight;//整个网页的高(包括边框) docunment.body.offsetHeight;//整个网页的滚动距离document.body.scrollTopdocument.body.scrollleft.

2021-03-05 10:41:03 518 1

原创 数组赋值

引用赋值-浅拷贝let arr1 = [1, 2, 3, 4, 5];let arr2 = arr1;console.log(arr2); //[1, 2, 3, 4, 5]arr1[0] = 22;console.log(arr2); //[22, 2, 3, 4, 5]循环遍历赋值-深拷贝let arr1 = [1, 2, 3, 4, 5];let arr3 = [];for(var i in arr1){ arr3.push(arr1[i]);}console.log

2021-02-23 18:37:56 116 1

原创 提取URL中某一参数name的value

queryString: ?name=value&name1=&name2=value2function getUrlQuery (name) { let reg = new RegExp('(^|&)'+name+'=([^&]*)(&|$)'); let value = window.location.search.subStr(1).match(reg); return value[2]}function getUrlQuery(url, name

2021-02-09 14:46:53 222

原创 javascript

Window对象概念:所有全局js对象,全局js函数,全局js变量,document对象都是windows对象成员window.document.getElementById();//等同于document.getElementById();浏览器窗口尺寸大小//window.innerHeight - 浏览器窗口的内高度(以像素计)//window.innerWidth - 浏览器窗口的内宽度(以像素计)//兼容var with = window.innerWidth || docu

2021-02-05 11:38:22 165

原创 正则方法

1. reg.test(str)param:待匹配字符串return:true/falseconsole.log(/hello/i.test('HelloWorld'))//trueconsole.log(/hello/.test('HelloWorld'))//false2. reg.exec(str)param:待匹配字符串return:array array[0]表示正则匹配到的字符串var reg = /\d+/g;var str = 'abcdt23tStri12';

2021-02-02 14:24:19 869

原创 封装跳转登陆页面

第一步:url.jsexport default { //不需要登陆的页面 excludePath:[...]}第二步:router.js/** * @description 解析路由,并拼接到登录链接中 e.g:/pages/login/login?redirect=要去的路径&要去路径参数 * @param url 当前需跳转的路由 * @returns {string} 带参数的登录路由地址 */ function getLoginPath(url) { let lo

2021-01-29 18:19:59 158

原创 水平方向不换行去掉滚动条

第一步:在vue中使用lessnpm install less less-loader --save第二步:<style lang='less'> overflow-x: scroll; white-space: nowrap; &::-webkit-scrollbar { display: none; }</style>

2021-01-28 17:06:39 202

原创 uni-app中实现动态导航栏

原理:同一页面的两处跳到同一页面,通过路由携带导航标题参数和uni-app中自定义导航栏API–uni.setNavigationBarTitle实现index.vue<template> <view @click="toSearch('搜索')"></view> <view @click="toSearch('全部')"></view></template><script> export default {

2021-01-11 18:32:38 1604

原创 组件-选项卡

基于vue/cli的uni-app选项卡切换<template><view class="drop-hidden" :class="{'none': !dropShow}"> <view class="drop-hidden_container"> <view v-for="(item, index) in list" :key="index" @click="click

2020-12-24 14:02:02 252 1

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除