自用vscode常用代码片段
随便设置的标题如何插入一段漂亮的代码片下面展示同样高亮的 代码片.#usernobody;worker_processes1;#error_loglogs/error.log;#error_loglogs/error.lognotice;#error_loglogs/error.loginfo;#pidlogs/nginx.pid;events {worker_connections1024;}h
·
自用vscode常用代码片段
html.json
{
// Place your snippets for html here. Each snippet is defined under a snippet name and has a prefix, body and
// description. The prefix is what is used to trigger the snippet and the body will be expanded and inserted. Possible variables are:
// $1, $2 for tab stops, $0 for the final cursor position, and ${1:label}, ${2:another} for placeholders. Placeholders with the
// same ids are connected.
// Example:
// "Print to console": {
// "prefix": "log",
// "body": [
// "console.log('$1');",
// "$2"
// ],
// "description": "Log output to console"
// }
"script": {
"prefix": "sci",
"body": [
"<script>",
"\t$1",
"</script>"
],
"description": "script"
},
"style": {
"prefix": "sty",
"body": [
"<style>",
"\t$1",
"</style>"
],
"description": "style"
},
"function": {
"prefix": "fun",
"body": [
"function(){",
"\t$1",
"}"
],
"description": "function"
},
"script(text/html)": {
"prefix": "my_temp",
"body": [
"<script id=\"$1\" type=\"text/html\">",
"\t",
"</script>"
],
"description": "模板引擎"
},
"axios(config)": {
"prefix": "as",
"body": [
"<div id='app'>",
"\t",
"</div>",
"<script src='./vue.js'></script>",
"<script src='./axios.js'></script>",
"<script>",
"\tnew Vue({",
"\t\tel:'#app',",
"\t\tdata:{",
"\t\t},",
"\t\tmethods: {",
"\t\t},",
"\t});",
"</script>"
],
"description": "axios(config配置模式使用)"
},
"vue(实例化)": {
"prefix": "vue",
"body": [
"<div id='app'>",
"\t",
"</div>",
"<script src='./vue.js'></script>",
"<script>",
"\tnew Vue({",
"\t\tel:'#app',",
"\t\tdata:{",
"\t\t},",
"\t\tmethods: {",
"\t\t},",
"\t});",
"</script>"
],
"description": "vue(实例化)"
},
}
javascript.json
{
// Place your snippets for javascript here. Each snippet is defined under a snippet name and has a prefix, body and
// description. The prefix is what is used to trigger the snippet and the body will be expanded and inserted. Possible variables are:
// $1, $2 for tab stops, $0 for the final cursor position, and ${1:label}, ${2:another} for placeholders. Placeholders with the
// same ids are connected.
// Example:
// "Print to console": {
// "prefix": "log",
// "body": [
// "console.log('$1');",
// "$2"
// ],
// "description": "Log output to console"
// }
"Print to console": {
"prefix": "lg",
"body": [
"console.log('$1');"
],
"description": "Log output to console"
},
"Print to console in vue": {
"prefix": "wlg",
"body": [
"window.console.log('$1');"
],
"description": "在vue中打印"
},
"window onload": {
"prefix": "wod",
"body": [
"window.onload = function () {",
"\t$1",
"}"
],
"description": "window onload"
},
"document.getElementById": {
"prefix": "dgi",
"body": [
"document.getElementById('$1')"
],
"description": "document.getElementById"
},
"document.createElement": {
"prefix": "dce",
"body": [
"document.createElement('$1')"
],
"description": "document.createElement"
},
"$(function ()": {
"prefix": "$f",
"body": [
"$(function () {",
"\t$1",
"});"
],
"description": "$(function ()入口函数"
},
"$()": {
"prefix": "$f",
"body": [
"$('$1')"
],
"description": "$()"
},
"function": {
"prefix": "fun",
"body": [
"function(){",
"\t$1",
"}"
],
"description": "function"
},
"my_ajax_postHeader": {
"prefix": "srh",
"body": [
"xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');"
],
"description": "原生js发送ajax的post请求,需要设置的请求头"
},
"my_jqajax_postHeader": {
"prefix": "jqa",
"body": [
"$.ajax({",
"\turl: '$1',",
"\ttype: 'post',",
"\tdataType: 'json',",
"\tdata: {},",
"\tsuccess: function (data) {",
"",
"\t}",
"});"
],
"description": "jq中的ajax请求"
},
"my_picPreview": {
"prefix": "pic",
"body": [
"$('上传文件的表单按钮').on('change',function(){",
"\tvar file = this.files[0];",
"\tvar url = URL.createObjectURL(file);",
"\t$('预览的图片img标签').attr('src',url);",
"});"
],
"description": "上传图片的预览"
},
"my_ajaxSubmit": {
"prefix": "fd",
"body": [
"$('提交按钮').on('click', function (e) {",
"\te.preventDefault();",
"\tvar fd = new FormData($('提交的form表单')[0]);",
"\t$.ajax({",
"\t\turl: '',",
"\t\ttype: 'post',",
"\t\tdataType: 'json',",
"\t\tdata: fd,",
"\t\tcontentType: false,",
"\t\tprocessData: false,",
"\t\tsuccess: function (data) {",
"\t\t\t",
"\t\t}",
"\t});",
"});"
],
"description": "fd形式提交"
},
"server_setHeader": {
"prefix": "acao",
"body": [
"res.setHeader('Access-Control-Allow-Origin','*');"
],
"description": "服务端设置响应头,解决跨域问题"
},
"function description": {
"prefix": "my_com",
"body": [
"/**",
"* @description:",
"* @param {type}",
"* @return:",
"*/"
],
"description": "函数注释"
},
"vue-router(路由配置)": {
"prefix": "vue-router",
"body": [
"import Vue from 'vue'",
"import App from './App.vue'",
"import VueRouter from 'vue-router'",
"Vue.use(VueRouter)",
"const router = new VueRouter({",
"\troutes: [",
"\t\t{}",
"\t]",
"});",
"Vue.config.productionTip = false",
"new Vue({",
"\trouter,",
"\trender: h => h(App),",
"}).$mount('#app');"
],
"description": "vue-router(路由配置)"
},
"解决vue中的NavigationDuplicated(导航重复)": {
"prefix": "vue-NavigationDuplicated",
"body": [
"const originalPush = VueRouter.prototype.push",
"VueRouter.prototype.push = function push(location) {",
"\treturn originalPush.call(this, location).catch(err => err)",
"}",
],
"description": "路由重复"
},
}
vue.json
{
// Place your snippets for vue here. Each snippet is defined under a snippet name and has a prefix, body and
// description. The prefix is what is used to trigger the snippet and the body will be expanded and inserted. Possible variables are:
// $1, $2 for tab stops, $0 for the final cursor position, and ${1:label}, ${2:another} for placeholders. Placeholders with the
// same ids are connected.
// Example:
// "Print to console": {
// "prefix": "log",
// "body": [
// "console.log('$1');",
// "$2"
// ],
// "description": "Log output to console"
// }
"vue of base": {
"prefix": "vue",
"body": [
"<template>",
"\t<div>",
"\t</div>",
"</template>",
"<script>",
"export default {};",
"</script>",
"<style>",
"</style>"
],
"description": "vue基本模板"
}
}
nginx的一些配置
#user nobody; worker_processes 1;
#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
#pid logs/nginx.pid; events {
worker_connections 1024; } http {
include mime.types;
default_type application/octet-stream;
#log_format main '$remote_addr - $remote_user [$time_local] "$request" '
# '$status $body_bytes_sent "$http_referer" '
# '"$http_user_agent" "$http_x_forwarded_for"';
#access_log logs/access.log main;
sendfile on;
#tcp_nopush on;
#keepalive_timeout 0;
keepalive_timeout 65;
#gzip on;
server {
listen 8886;
server_name localhost;
#charset koi8-r;
#access_log logs/host.access.log main;
#location / {
root html;
index index.html index.htm;
#} # location /api { #用不上
# rewrite ^/api/(.*)$ /$1 break; #可选参数,正则验证地址
# include uwsgi_params; #可选参数,uwsgi是服务器和服务端应用程序的通信协议,规定了怎么把请求转发给应用程序和返回
# proxy_pass http://0.0.0.0:8567; #此处修改为自己的请求地址,必填
# }
# location / {
# proxy_pass http://localhost:8080;
# }
location /captcha {
include uwsgi_params;
proxy_pass http://0.0.0.0:8567;
}
location /api {
rewrite ^/api/(.*)$ /$1 break;
include uwsgi_params;
proxy_pass http://0.0.0.0:8567;
}
location /login {
include uwsgi_params;
proxy_pass http://0.0.0.0:8567;
}
location /info {
include uwsgi_params;
proxy_pass http://0.0.0.0:8567;
}
# location /data {
# include uwsgi_params;
# proxy_pass http://0.0.0.0:8567;
# }
# location /upload {
# include uwsgi_params;
# proxy_pass http://0.0.0.0:8567;
# }
# location / {
# proxy_pass http://localhost:8081;
# proxy_http_version 1.1;
# }
location /img {
include uwsgi_params; #可选参数,uwsgi是服务器和服务端应用程序的通信协议,规定了怎么把请求转发给应用程序和返回
proxy_pass https://www.baidu.com/; # 后端接口 IP:port
}
# location / {
# add_header Access-Control-Allow-Origin *;
# }
location ~ .*\.(js|css|png|jpg|woff|ttf)$ #这是是需要加载文件的正则过滤 如果有其他文件再加上即可
{
root html/dist/; #//这是网站根目录
if (-f $request_filename) {
expires 1d;
break;
}
}
#error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
# proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
#location ~ \.php$ {
# proxy_pass http://127.0.0.1;
#}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
#location ~ \.php$ {
# root html;
# fastcgi_pass 127.0.0.1:9000;
# fastcgi_index index.php;
# fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
# include fastcgi_params;
#}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
# deny all;
#}
}
# another virtual host using mix of IP-, name-, and port-based configuration
#
#server {
# listen 8000;
# listen somename:8080;
# server_name somename alias another.alias;
# location / {
# root html;
# index index.html index.htm;
# }
#}
# HTTPS server
#
#server {
# listen 443 ssl;
# server_name localhost;
# ssl_certificate cert.pem;
# ssl_certificate_key cert.key;
# ssl_session_cache shared:SSL:1m;
# ssl_session_timeout 5m;
# ssl_ciphers HIGH:!aNULL:!MD5;
# ssl_prefer_server_ciphers on;
# location / {
# root html;
# index index.html index.htm;
# }
#}
}
更多推荐
所有评论(0)