Attention: the list was moved to
https://github.com/dypsilon/frontend-dev-bookmarks
This page is not maintained anymore, please update your bookmarks.
// 简单工厂模式 - 创建对象 | |
function createFactoryProxy(source, handler) { | |
// todo 扩展成为单例 | |
const resultTmp = {} | |
var proxyInst = new Proxy(source, { | |
set(target, property, value, receiver) { | |
if (Reflect.has(resultTmp, property)) { | |
throw new Error('已经设置代理属性, 不能再次设置') | |
} else { | |
Reflect.defineProperty(resultTmp, property, { |
# set the base image to Debian | |
# https://hub.docker.com/_/debian/ | |
FROM debian:latest | |
# replace shell with bash so we can source files | |
RUN rm /bin/sh && ln -s /bin/bash /bin/sh | |
# update the repository sources list | |
# and install dependencies | |
RUN apt-get update \ |
function kebabCase(str) { | |
const hyphenateRE = /([^-])([A-Z])/g; | |
return str | |
.replace(hyphenateRE, '$1-$2') | |
.replace(hyphenateRE, '$1-$2') | |
.toLowerCase(); | |
} |
var _ = require("lodash"); | |
var R = require("ramda"); | |
var companies = [ | |
{ name: "tw", since: 1993 }, | |
{ name: "pucrs", since: 1930 }, | |
{ name: "tw br", since: 2009 } | |
]; | |
var r1 = _(companies).chain() |
Attention: the list was moved to
https://github.com/dypsilon/frontend-dev-bookmarks
This page is not maintained anymore, please update your bookmarks.
# to generate your dhparam.pem file, run in the terminal | |
openssl dhparam -out /etc/nginx/ssl/dhparam.pem 2048 |
{ | |
chainWebpack: (config) =>{ | |
// ... | |
// sass 处理 | |
config.module.rules.delete('scss') | |
let scssRule = config.module.rule('scss') | |
.test(/\.scss$/); | |
[ | |
{ name: 'vue-style-loader' }, |
判断滚动条的需求在弹窗插件中使用比较多,当弹窗添加overflow: hidden时,如果页面比较长的话,添加这个属性之后页面会有晃动。 | |
为了增强用户体验,通过判断是否有滚动条而添加 margin-left 属性以抵消 overflow: hidden 之后的滚动条位置。 | |
判断是否有滚动条的方法 | |
function hasScrollbar() { | |
return document.body.scrollHeight > (window.innerHeight || document.documentElement.clientHeight); | |
} | |
计算滚动条宽度的方法 | |
新建一个带有滚动条的 div 元素,通过该元素的 offsetWidth 和 clientWidth 的差值即可获得 |
function CopyToClipboard(option) { | |
var textToClipboard = option.text | |
function CreateElementForExecCommand (textToClipboard) { | |
var forExecElement = document.createElement ("div"); | |
// place outside the visible area | |
forExecElement.style.position = "absolute"; | |
forExecElement.style.left = "-10000px"; | |
forExecElement.style.top = "-10000px"; | |
// write the necessary text into the element and append to the document | |
forExecElement.textContent = textToClipboard; |
var express = require('express'); | |
var http = require('http') | |
var app = express(); | |
var http_app = http.Server(app); | |
var proxy = require('express-http-proxy') | |
const remote = proxy("真实接口地址", { |