zoukankan      html  css  js  c++  java
  • Live2d Test Env

    该博文作为uniapp的通用笔记项

    1. 在mounted函数内发送请求

    2. 路由跳转时添加动画:

    uni.navigateTo({
    	url: '../demo/index',
    	animationType: 'pop-in',
    	animationDuration: 200
    })
    
    1. 设置缓存时添加success方法:
    uni.setStorage({
    	key: 'storage_',
    	data: images.small,
    	success: function() {
    	      console.log(`item.images.small`);
    	}
    })
    
    1. 对数组对象进行过滤,num表示要保留数组内几个对象,默认保留三个以下
    filterArr(arr, num = 3){
    				if(arr.length <= 2) {
    					return  arr
    				}
    				let newArr = arr.filter((e,i)=>{
    					return i  <  num  
    				})
    				return newArr
    },
    
    
    1. 判断对象的内容是否为空
      Object.keys(obj).length
    2. 判断数组是否为空
      arr.length
    3. 简单日期过滤,仅保留年月日
    filterTime(val){
    				if(val !== null && val !== undefined){
    					if(val.length > 10){
    						return  val.slice(0,10)
    					}
    					return val
    				}
    				 
    				 return val
    			},
    
    1. 剔除富文本中的标签,如果有多个使用冒号分隔
    	// 正则匹配
    filterP(val){
    	if(val!==null && val !== ' ' && val !== undefined ){
    	let req = /</?(?:p)[^>]*>/g
    	return val.replace(req,'')
    	}else{
    	 return '-'
    	}
    }
    

    七个关于背景图的骚操作 摘自https://zhuanlan.zhihu.com/p/148204848?utm_source=qq&utm_medium=social

    1 背景图自适应

    body {
      background-image: url('https://images.unsplash.com/photo-1573480813647-552e9b7b5394?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=2253&q=80');
      background-repeat: no-repeat;
      background-position: center;
      background-attachment: fixed;
      background-size: cover;
      -webkit-background-size: cover;
      -moz-background-size: cover;
      -o-background-size: cover;
    }
    

    2 单个容器单位内添加多张背景图

    body {
      background-image:
                 url(https://image.flaticon.com/icons/svg/748/748122.svg), 
                 url(https://images.unsplash.com/photo-1478719059408-592965723cbc?ixlib=rb-1.2.1&auto=format&fit=crop&w=2212&q=80);
      background-position: center, top;
      background-repeat: repeat, no-repeat;
      background-size: contain, cover;
    }
    

    3 创建一个三角形背景
    思路是这样的,首先创建两个div,然后将两个背景都添加到其中,然后,第二个div使用clip-path属性画出三角形。

    <body>
      <div class="day"></div>
      <div class="night"></div>
    </body>
    
    body {
      margin: 0;
      padding: 0;
    }
    
    div {
      position: absolute;
      height: 100vh;
       100vw;
    }
    
    .day {
      background-image: url("https://images.unsplash.com/photo-1477959858617-67f85cf4f1df?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=2613&q=80");
      background-size: cover;
      background-repeat: no-repeat;
    }
    
    .night {
      background-image: url("https://images.unsplash.com/photo-1493540447904-49763eecf55f?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=2250&q=80");
      background-size: cover;
      background-repeat: no-repeat;
      clip-path: polygon(100vw 0, 0% 0vh, 100vw 100vh);
    }
    
    1. 背景图像上添加叠加渐变
    body {
      background-image: 
        linear-gradient(4deg, rgba(38,8,31,0.75) 30%, rgba(213,49,127,0.3) 45%, rgba(232,120,12,0.3) 100%),
        url("https://images.unsplash.com/photo-1503803548695-c2a7b4a5b875?ixlib=rb-1.2.1&auto=format&fit=crop&w=2250&q=80");
      background-size: cover;
      background-repeat: no-repeat;
      background-attachment: fixed;
      background-position: center
    }
    

    5.创建一个颜色动态变化的背景

    HTML CSSResult
    EDIT ON
    @keyframes background-overlay-animation {
      0%   {
          background-image: 
            linear-gradient(4deg, rgba(255,78,36,0.3) 50%, rgba(255,78,36,0.3) 100%), url("https://images.unsplash.com/photo-1559310589-2673bfe16970?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=2250&q=80");
      }
      25%  {
          background-image: 
             linear-gradient(4deg, rgba(213,49,127,0.3) 50%, rgba(213,49,127,0.3) 100%), url("https://images.unsplash.com/photo-1559310589-2673bfe16970?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=2250&q=80");
      }
      50%  {
        background-image: 
           linear-gradient(4deg, rgba(36,182,255,0.3) 50%, rgba(36,182,255,1) 100%),
         url("https://images.unsplash.com/photo-1559310589-2673bfe16970?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=2250&q=80");
      }
      100% {
        background-image: 
            linear-gradient(4deg, rgba(0,255,254,0.3) 50%, rgba(0,255,254,0.3) 100%),
            url("https://images.unsplash.com/photo-1559310589-2673bfe16970?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=2250&q=80");
      }
    }
    
    @-webkit-keyframes background-overlay-animation {
      0%   {
          background-image: 
            linear-gradient(4deg, rgba(255,78,36,0.3) 50%, rgba(255,78,36,0.3) 100%)
            url("https://images.unsplash.com/photo-1559310589-2673bfe16970?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=2250&q=80");
      }
      25%  {
          background-image: 
             linear-gradient(4deg, rgba(213,49,127,0.3) 50%, rgba(213,49,127,0.3) 100%),
            url("https://images.unsplash.com/photo-1559310589-2673bfe16970?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=2250&q=80");
      }
      50%  {
        background-image: 
           linear-gradient(4deg, rgba(36,182,255,0.3) 50%, rgba(36,182,255,1) 100%),
         url("https://images.unsplash.com/photo-1559310589-2673bfe16970?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=2250&q=80");
      }
      100% {
        background-image: 
            linear-gradient(4deg, rgba(0,255,254,0.3) 50%, rgba(0,255,254,0.3) 100%),
          }
    

    7 制作网格背景图像

    <body>
    <div class="container">
      <div class="item_img"></div>
      <div class="item"></div>
      <div class="item_img"></div>
      <div class="item"></div>
      <div class="item"></div>
      <div class="item_img"></div>
      <div class="item"></div>
      <div class="item_img"></div>
      <div class="item"></div>
      <div class="item"></div>
      <div class="item_img"></div>
      <div class="item"></div>
      <div class="item_img"></div>
      <div class="item"></div>
      <div class="item_img"></div>
      <div class="item"></div>
    </div>
    </body>
    
    body {
     margin: 0;
      padding: 0;
    }
    
    .container {
      position: absolute;
       100%;
      height: 100%;
      background: black;
      display: grid;
      grid-template-columns: 25fr 30fr 40fr 15fr;
      grid-template-rows: 20fr 45fr 5fr 30fr;
      grid-gap: 20px;
      .item_img {
        background-image: url('https://images.unsplash.com/photo-1499856871958-5b9627545d1a?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=2207&q=80');
      background-repeat: no-repeat;
      background-position: center;
      background-attachment: fixed;
      background-size: cover;
    }
    }
    

    7 将背景图像设置为文本颜色(类似ps填充效果)
    原理:使用background-image与 background-clip

    <body>
      <h1>Hello world!</h1>
    </body>
    
    body {
      display: flex;
      align-items: center;
      justify-content: center;
      flex-direction: column;
       100%;
      text-align: center;
      min-height: 100vh;
      font-size: 120px;
      font-family:Arial, Helvetica, sans-serif;
    }
    
    h1 {
       background-image: url("https://images.unsplash.com/photo-1462275646964-a0e3386b89fa?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=2600&q=80");
      background-clip: text;
      -webkit-background-clip: text;
      color: transparent;
    }
    

    待续

  • 相关阅读:
    vue嵌套路由
    不同的网络出现的报错
    yarn 创建react项目时出现错误
    vue-awsome-swiper竖向滚动出现空白
    SpringBoot路径映射
    ApplicationRunner接口
    CommandLineRunner接口
    springboot创建拦截器
    Cors跨域请求
    springboot自定义异常视图
  • 原文地址:https://www.cnblogs.com/hjk1124/p/13234594.html
Copyright © 2011-2022 走看看