Skip to content

Instantly share code, notes, and snippets.

View magicianShiro's full-sized avatar
🏠
Working from home

NAVI magicianShiro

🏠
Working from home
View GitHub Profile
@magicianShiro
magicianShiro / app.js
Last active August 25, 2017 08:18
使用rest风格发送请求, 跨域时关于服务器端的设置
// 设置请求头来实现跨域, 允许请求头和方法
app.use((req, res, next) => {
res.header("Access-Control-Allow-Origin", "*")
res.header("Access-Control-Allow-Headers", "Content-Type,Content-Length, Authorization, Accept,X-Requested-With")
res.header("Access-Control-Allow-Methods","PUT,POST,GET,DELETE,OPTIONS")
next()
})
// 设置前端可以从响应头中获取那些信息
Access-Control-Expose-Headers : '要获取的响应头中的舰值'
@magicianShiro
magicianShiro / gist:19dab7f56a385c1a31cb06ea46f0eea2
Last active March 31, 2017 08:06
input 为number类型时 去掉 上下箭头
<input type="number" ...>
<style>
input::-webkit-outer-spin-button,
input::-webkit-inner-spin-button {
-webkit-appearance: none;
}
input[type="number"]{
-moz-appearance: textfield;
}
@magicianShiro
magicianShiro / webpack-loder.txt
Last active June 19, 2017 08:42
关于webpack的一些loader
babel的loader
babel-core
babel-loader
babel-preset-es2015
不知道作用的
babel-plugin-add-module-exports
babel-plugin-syntax-dynamic-import
babel-plugin-transform-es2015-modules-umd
配合eslint使用的
babel-eslint
@magicianShiro
magicianShiro / buffer.js
Created July 1, 2017 04:33
拼接buffer
var chunks = [];
var size = 0;
res.on('data', function (chunk) {
chunks.push(chunk);
size += chunk.length;
});
res.on('end', function () {
var data = null;
switch(chunks.length) {
case 0: data = new Buffer(0);
@magicianShiro
magicianShiro / meta.txt
Created November 21, 2017 09:55
移动端meta
<!--使用 viewport meta 标签在手机浏览器上控制布局-->
<meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1" />
<!--通过快捷方式打开时全屏显示-->
<meta name="apple-mobile-web-app-capable" content="yes" />
<!--隐藏状态栏-->
<meta name="apple-mobile-web-app-status-bar-style" content="blank" />
<!--iPhone会将看起来像电话号码的数字添加电话连接,应当关闭-->
<meta name="format-detection" content="telephone=no" />
@magicianShiro
magicianShiro / main.css
Created February 10, 2018 02:37
关于页面上有滚动和无滚动时导致页面左右抖动的问题
html
overflow-y scroll
:root
overflow-y auto
overflow-x hidden
:root body
position absolute
@magicianShiro
magicianShiro / autoTextarea
Created April 18, 2018 07:00
textarea自动撑大
/**
* 文本框根据输入内容自适应高度
* @param {HTMLElement} 输入框元素
* @param {Number} 设置光标与输入框保持的距离(默认0)
* @param {Number} 设置最大高度(可选)
*/
autoTextarea (elem, extra, maxHeight) {
let _this = this
let fontSize = this.get_fontsize()
extra = extra || 0;
@magicianShiro
magicianShiro / input.vue
Created August 16, 2018 12:27
mpvue中input 使用 v-model 导致光标抖动
const vModelBugfillMixin = {
data() {
return {
ownValue: null,
};
},
model: {
prop: 'valueFromProp',
},
props: {
@magicianShiro
magicianShiro / circle.html
Created September 10, 2018 09:33
css绘制没有缝隙的原型进度条
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>Page Title</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<style>
#loading {
@magicianShiro
magicianShiro / circle.html
Created September 10, 2018 09:59
css绘制没有缝隙的圆形进度条--非clip
<html>
<head>
<title>Parcel Sandbox</title>
<meta charset="UTF-8" />
</head>
<style>
.circle_process{
position: relative;
width: 200px;
height : 200px;