分类 前端笔记 下的文章

添加catchtouchmove


    <view wx:if="{{alert}}" catchtouchmove="myCatchTouch">
        <template is="alert" data="{{alertData}}" />
    </view>
  myCatchTouch: function () {
    console.log('stop user scroll it!');
    return;
  },

针对catchtouchmove方法,原生小程序使用catchtouchmove="touchmoveHandler",mpvue中使用@touchmove.stop="touchmoveHandler",注意要给个空方法,否则会报警

CSS

给遮罩层加css

height: 100vh;
overflow: hidden;

添加.babelrc

{
  "presets": [
    "es2015"
  ]
}

安装插件

  • yarn
yarn add babel-preset-es2015
  • npm
npm install babel-preset-es2015 --save

以babel-node运行

运行命令后边添加--exec babel-node

原文地址

在本文中我将展示用gulp压缩css的简单方法

开始-什么是gulp

Gulp是一个javascript的自动化构建工具,他可以自动完成例如以下的任务……

  • 绑定压缩资源和样式
  • 热加载
  • 快速运行单元测试
  • Less/Sass 编译成CSS
  • 更多

gulp的工作原理流程如下:

单行

.class{
    overflow: hidden;
    text-overflow:ellipsis;
    white-space: nowrap;
}

多行

.class{
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 3;
    overflow: hidden;
}

  • -webkit-line-clamp用来限制在一个块元素显示的文本的行数。 为了实现该效果,它需要组合其他的WebKit属性。常见结合属性:
  • display: -webkit-box; 必须结合的属性 ,将对象作为弹性伸缩盒子模型显示 。
  • -webkit-box-orient 必须结合的属性 ,设置或检索伸缩盒对象的子元素的排列方式 。

实现方法

p{position: relative; line-height: 20px; max-height: 40px;overflow: hidden;}
p::after{content: "..."; position: absolute; bottom: 0; right: 0; padding-left: 40px;
background: -webkit-linear-gradient(left, transparent, #fff 55%);
background: -o-linear-gradient(right, transparent, #fff 55%);
background: -moz-linear-gradient(right, transparent, #fff 55%);
background: linear-gradient(to right, transparent, #fff 55%);
}

截止2018-12-26,最先版本的小程序依旧不支持ES7的语法Async/Await

为了让小程序支持Async/Await,这里要用到一个库regenerator

我们最终要引用到的文件就是regenerator-runtime.js

在utils中import

import regeneratorRuntime from './regenerator-runtime/runtime-module'

正常使用Async/Await即可!

(没有抓住圣诞节的尾巴,就依旧只能提前祝自己狗狗快乐一声了)