外贸关键词网站,怎么做互联网推广,wordpress文章版权插件,寿光网站建设推广做开发总是会有大量的代码要写#xff0c;但是有时候某些代码是非常基础但是很多#xff0c;我们就可以把这一部分整合起来#xff0c;使用一个很简短的关键字来快速唤出。 如何新建这样的代码段#xff1f;
1.在VSCode当中找到Snippets#xff0c;然后点击
2.之后会弹出…做开发总是会有大量的代码要写但是有时候某些代码是非常基础但是很多我们就可以把这一部分整合起来使用一个很简短的关键字来快速唤出。 如何新建这样的代码段
1.在VSCode当中找到Snippets然后点击
2.之后会弹出一个框选择New Global Snippets file
3.弹出一个小框你在这里书写该自定义代码片段的名称记得复制下来
4.然后进入具体的文件就像下面这样 默认模板如下
{// Place your global snippets here. Each snippet is defined under a snippet name and has a scope, prefix, body and // description. Add comma separated ids of the languages where the snippet is applicable in the scope field. If scope // is left empty or omitted, the snippet gets applied to all languages. 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: {// scope: javascript,typescript,// prefix: log,// body: [// console.log($1);,// $2// ],// description: Log output to console// }
}
有哪些模板
自定义axios拦截器并封装
{ // 代码片段的名称这个名称会显示在代码片段列表中 axiost: { prefix: axiost, // 触发代码片段的关键字 body: [ import axios, { AxiosInstance, InternalAxiosRequestConfig } from axios;, , const creatAxios (config?: InternalAxiosRequestConfig) {, \tconsole.log(打印配置信息, import.meta.env);, \tconst instance: AxiosInstance axios.create({, \t\tbaseURL: import.meta.env.VITE_API_BASE_URL,, \t\ttimeout: import.meta.env.VITE_TIMEOUT,, \t\twithCredentials: true, // default-false 跨域请求是否需要凭证, \t\theaders: {, \t\t\tContent-Type: application/json,, \t\t\tAccept: application/json,, \t\t},, \t\t...config,, \t});, , \t// 重写请求拦截器规则, \tinstance.interceptors.request.use(, \t\t(config: InternalAxiosRequestConfig) {, \t\t\t// 在发送请求之前做些什么, \t\t\tconsole.log(在发送请求之前做些什么呢);, \t\t\treturn config;, \t\t},, \t\t(error: any) {, \t\t\t// 对请求错误做些什么, \t\t\tconsole.log(对请求错误做些什么呢);, \t\t\treturn Promise.reject(error);, \t\t},, \t);, , \t// 重写响应拦截器规则, \tinstance.interceptors.response.use(, \t\t(response: any) {, \t\t\t// 对响应数据做点什么, \t\t\tconsole.log(对响应数据做点什么呢, response.data.msg);, \t\t\tif (response.data.code ! 200) {, \t\t\t\tconsole.error(response.data.msg);, \t\t\t} else {, \t\t\t\tconsole.log(response.data.msg);, \t\t\t}, \t\t\treturn response;, \t\t},, \t\t(error: any) {, \t\t\t// 对响应错误做点什么, \t\t\tconsole.log(对响应错误做点什么呢, error);, \t\t\treturn Promise.reject(error);, \t\t},, \t);, , \treturn instance;, }; ], description: 快速生成一个创建Axios实例的函数 }
}
在html引入echarts
{// Place your global snippets here. Each snippet is defined under a snippet name and has a scope, prefix, body and // description. Add comma separated ids of the languages where the snippet is applicable in the scope field. If scope // is left empty or omitted, the snippet gets applied to all languages. 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:echartsUrl: {scope: javascript,typescript,html,prefix: echartsUrl,body: [script src\https://cdn.jsdelivr.net/npm/echarts/dist/echarts.min.js\/script],description: Log output to console}
}
html板子这个其实你输入感叹号也可以实现
{ // 这里是文件的全局描述不是必须的但有助于理解 HTML Templates: { // 定义一个前缀当在HTML文件中输入此前缀并按下Tab时将展开此片段 Print to console: { prefix: htmlt, // 描述可选 description: Log output to console, // 片段内容 body: [ !DOCTYPE html, html lang\en\, head, meta charset\UTF-8\, meta name\viewport\ content\widthdevice-width, initial-scale1.0\, titleDocument/title, /head, body, h1Hello, World!/h1, !-- Your HTML content goes here --, /body, /html ] } }
}
html表的模板
{// Place your global snippets here. Each snippet is defined under a snippet name and has a scope, prefix, body and // description. Add comma separated ids of the languages where the snippet is applicable in the scope field. If scope // is left empty or omitted, the snippet gets applied to all languages. 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:htmltabelt: {scope: javascript,typescript,html,prefix: htmltabelt,body: [div id\root\ style\width: 100vw;height: 100vh\, table, thead, tr, thxxxxx/th, /tr, /thead, tbody, tr, td% value.xxx%/td, /tr, /tbody, /table,/div,],description: Log output to console}
}
html表格样式
{// Place your global snippets here. Each snippet is defined under a snippet name and has a scope, prefix, body and // description. Add comma separated ids of the languages where the snippet is applicable in the scope field. If scope // is left empty or omitted, the snippet gets applied to all languages. 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:tablestylet: {scope: javascript,typescript,html,prefix: tablestylet,body: [style,font-face {, font-family: \PingFang SC\;, src: url(\https://oms-2018-test.oss-cn-hangzhou.aliyuncs.com/template/PingFang_SC_Standard.ttf\);,},* {, margin: 0;, padding: 0;,},#root {, font-family: \PingFang SC\;, font-size: 32px;, width: 100%;,},.redtext {, color: #e8380d;,},.yellowtext {, color: #ffbc3c;,},table {, border-collapse: collapse;, width: 100%;,},th,,td {, border: 1px solid #e8e8e8;, padding: 8px;, text-align: center;,},thead tr:first-child th {, background-color: #eee;, color: #000;, text-align: center;,},tbody tr:last-child td {, font-weight: bold;,},/style,],description: Log output to console}
}
js打印调试语句
{// Place your global snippets here. Each snippet is defined under a snippet name and has a scope, prefix, body and // description. Add comma separated ids of the languages where the snippet is applicable in the scope field. If scope // is left empty or omitted, the snippet gets applied to all languages. 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:logs: {scope: javascript,typescript,vue,prefix: logs,body: [console.log(xxxxx);,],description: Log output to console}
}
Vue3组合式快速模板
{// Place your global snippets here. Each snippet is defined under a snippet name and has a scope, prefix, body and // description. Add comma separated ids of the languages where the snippet is applicable in the scope field. If scope // is left empty or omitted, the snippet gets applied to all languages. 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:vuet: { //快捷输入的时候显示的提示prefix: vuet,//输入的前缀就是输入这个会有提示description: vue3模板,//描述body: [//这个是一个字符串数组就是会输出的内容如果内容含有 双引号需要转义比如最下面的lang\scss\template, div/div,/template,,script lang\ts\ setup,,/script,,style lang\scss\ scoped,/style,]
},
}
最后想说的
代码片段只是提效的手段作为程序员应该发挥想象力。我这里只是抛砖引玉介绍一下我的提效方式你完全可以根据自身特点利用这个功能来做自己的片段 文章转载自: http://www.morning.fpzz1.cn.gov.cn.fpzz1.cn http://www.morning.xmrmk.cn.gov.cn.xmrmk.cn http://www.morning.qrgfw.cn.gov.cn.qrgfw.cn http://www.morning.bnfjh.cn.gov.cn.bnfjh.cn http://www.morning.qshxh.cn.gov.cn.qshxh.cn http://www.morning.rzrbw.cn.gov.cn.rzrbw.cn http://www.morning.tkhyk.cn.gov.cn.tkhyk.cn http://www.morning.bpzw.cn.gov.cn.bpzw.cn http://www.morning.junyaod.com.gov.cn.junyaod.com http://www.morning.gcqkb.cn.gov.cn.gcqkb.cn http://www.morning.sjjtz.cn.gov.cn.sjjtz.cn http://www.morning.rwpjq.cn.gov.cn.rwpjq.cn http://www.morning.gbyng.cn.gov.cn.gbyng.cn http://www.morning.yaqi6.com.gov.cn.yaqi6.com http://www.morning.tcxk.cn.gov.cn.tcxk.cn http://www.morning.lffrh.cn.gov.cn.lffrh.cn http://www.morning.xrhst.cn.gov.cn.xrhst.cn http://www.morning.jllnh.cn.gov.cn.jllnh.cn http://www.morning.tpqzs.cn.gov.cn.tpqzs.cn http://www.morning.yhywr.cn.gov.cn.yhywr.cn http://www.morning.zwzlf.cn.gov.cn.zwzlf.cn http://www.morning.zjcmr.cn.gov.cn.zjcmr.cn http://www.morning.mzwfw.cn.gov.cn.mzwfw.cn http://www.morning.lwzpp.cn.gov.cn.lwzpp.cn http://www.morning.tlnkz.cn.gov.cn.tlnkz.cn http://www.morning.qxlhj.cn.gov.cn.qxlhj.cn http://www.morning.ssjtr.cn.gov.cn.ssjtr.cn http://www.morning.feites.com.gov.cn.feites.com http://www.morning.jbtwq.cn.gov.cn.jbtwq.cn http://www.morning.swkzk.cn.gov.cn.swkzk.cn http://www.morning.pdkht.cn.gov.cn.pdkht.cn http://www.morning.wcqxj.cn.gov.cn.wcqxj.cn http://www.morning.rpzqk.cn.gov.cn.rpzqk.cn http://www.morning.kcrw.cn.gov.cn.kcrw.cn http://www.morning.qnbsx.cn.gov.cn.qnbsx.cn http://www.morning.yldgw.cn.gov.cn.yldgw.cn http://www.morning.tnzwm.cn.gov.cn.tnzwm.cn http://www.morning.rwbh.cn.gov.cn.rwbh.cn http://www.morning.fzwf.cn.gov.cn.fzwf.cn http://www.morning.kzcfp.cn.gov.cn.kzcfp.cn http://www.morning.tpssx.cn.gov.cn.tpssx.cn http://www.morning.sgbk.cn.gov.cn.sgbk.cn http://www.morning.brscd.cn.gov.cn.brscd.cn http://www.morning.gghhmi.cn.gov.cn.gghhmi.cn http://www.morning.gkmwk.cn.gov.cn.gkmwk.cn http://www.morning.pnbls.cn.gov.cn.pnbls.cn http://www.morning.skrh.cn.gov.cn.skrh.cn http://www.morning.yxnkr.cn.gov.cn.yxnkr.cn http://www.morning.ryfq.cn.gov.cn.ryfq.cn http://www.morning.knscf.cn.gov.cn.knscf.cn http://www.morning.yrbp.cn.gov.cn.yrbp.cn http://www.morning.rklgm.cn.gov.cn.rklgm.cn http://www.morning.gbkkt.cn.gov.cn.gbkkt.cn http://www.morning.kfhm.cn.gov.cn.kfhm.cn http://www.morning.lyhry.cn.gov.cn.lyhry.cn http://www.morning.xmttd.cn.gov.cn.xmttd.cn http://www.morning.nndbz.cn.gov.cn.nndbz.cn http://www.morning.mhybs.cn.gov.cn.mhybs.cn http://www.morning.bwkhp.cn.gov.cn.bwkhp.cn http://www.morning.nktxr.cn.gov.cn.nktxr.cn http://www.morning.wnnfh.cn.gov.cn.wnnfh.cn http://www.morning.dkzrs.cn.gov.cn.dkzrs.cn http://www.morning.ptxwg.cn.gov.cn.ptxwg.cn http://www.morning.lkrmp.cn.gov.cn.lkrmp.cn http://www.morning.pmdlk.cn.gov.cn.pmdlk.cn http://www.morning.wbqt.cn.gov.cn.wbqt.cn http://www.morning.ntqqm.cn.gov.cn.ntqqm.cn http://www.morning.qkrqt.cn.gov.cn.qkrqt.cn http://www.morning.mdjtk.cn.gov.cn.mdjtk.cn http://www.morning.cxtbh.cn.gov.cn.cxtbh.cn http://www.morning.nzmqn.cn.gov.cn.nzmqn.cn http://www.morning.nzmhk.cn.gov.cn.nzmhk.cn http://www.morning.czgfn.cn.gov.cn.czgfn.cn http://www.morning.srkzd.cn.gov.cn.srkzd.cn http://www.morning.bhjyh.cn.gov.cn.bhjyh.cn http://www.morning.bfrff.cn.gov.cn.bfrff.cn http://www.morning.weiwt.com.gov.cn.weiwt.com http://www.morning.pctsq.cn.gov.cn.pctsq.cn http://www.morning.rxgnn.cn.gov.cn.rxgnn.cn http://www.morning.rgxll.cn.gov.cn.rgxll.cn