Giter Site home page Giter Site logo

code-collection's Introduction

就是各种自己写的代码片段咯

code-collection's People

Contributors

heziyang1993 avatar

Stargazers

 avatar

Forkers

heightzhang

code-collection's Issues

document.createDocumentFragment()

fragment文档碎片
createDocumentFragment()用法示例
// 一般插入节点方法
使用appendChild逐个向DOM文档中添加1000个新节点:
for (var i = 0; i < 1000; i++)
{
var el = document.createElement('p');
el.innerHTML = i;
document.body.appendChild(el);
}

// 使用createDocumentFragment()一次性向DOM文档中添加1000个新节点:
var frag = document.createDocumentFragment();
for (var i = 0; i < 1000; i++)
{
var el = document.createElement('p');
el.innerHTML = i; frag.appendChild(el);
}
document.body.appendChild(frag);

不要小瞧这10%-30%,效率的提高是着眼于多个细节的,如果我们能在很多地方都能让程序运行速度提高10%-30%,那将是一个质的飞跃,您也将步入骨灰级玩家的行列。

exports,module.exports,export default区别

exports,module.exports都是表示一个对象,暴露接口时候要写
exports.a = xxx;
module.exports.b = xxx;
读取时
import { a , b } from 'xxxx'
a和b就是对应上面的a和b
而export default则是后面跟什么就暴露什么,跟数字,就输出数组,跟对象就是输出对象
var a = 1;
export default { a : 1 }/export default a;
读取时
import a from 'xxx'即可

触发options请求

It uses methods other than GET, HEAD or POST. Also, if POST is used to send request data with a Content-Type other than application/x-www-form-urlencoded, multipart/form-data, ortext/plain, e.g. if the POST request sends an XML payload to the server using application/xmlor text/xml, then the request is preflighted.It sets custom headers in the request (e.g. the request uses a header such as X-PINGOTHER)

正则(?=)(?!)

(?!xxxx) 是正则表达式的负向零宽断言一种形式,标识预该位置后不是xxxx字符。
(?=xxxx) 是正则表达式的负向零宽断言一种形式,标识预该位置后都是xxxx字符。
(?:xxxx),匹配xxxx, 但是不会单独分组


(?![0-9]+$).test(888) // 匹配到1个
(?=[0-9]+$).test(888) // 匹配到3个

vue $nextTick注意事项

在使用钩子函数实现动画的时候注意dom的异步刷新,需要结合this.$nextTick(),同时在leave和enter中设置样式前最好迫使dom进行回流(reflow)使dom重新渲染,如获取元素的offsetHeight等,然后在this.$nextTick()中设置新的样式,不然有可能实现不了动画的效果.

移动端fixed问题

移动端滚动使用overflow-scrolling:touch,如果在滚动层使用overflow:auto等,会造成回弹的时候把fixed遮掉

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.