用户代码--常用的代码块

在这里插入图片描述

{
// 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 letiables 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('KaTeX parse error: Expected 'EOF', got '}' at position 54: …t to console" }̲, "xianshi yua…('KaTeX parse error: Undefined control sequence: \n at position 27: …ck',function(){\̲n̲", "})", ]…(‘file表单’).change(function () {”,
“\t//1.2 获取用户选择的图片”,
“\tlet file = this.files[0]”,
“\t//1.3 将文件转为src路径”,
“\tlet url = URL.createObjectURL(file)”,
“\t//1.4 将url路径赋值给img标签的src”,
“\tKaTeX parse error: Expected 'EOF', got '}' at position 34: …c', url)", "}̲)" ], "desc….ajax({”,
“\ttype:‘get’,”,
“\turl:‘’,”,
“\tdataType:‘json’,”,
“\tdata:‘’,”,
“\tsuccess: function(backData){”,
“”,
“\t}”,
“})”
],
“description”: “ajax请求”
},
“get for XMLHTTPRequest”: {
“prefix”: “ajax1”,
“body”: [
“//(1).实例化ajax对象”,
“let xhr = new XMLHttpRequest()”,
“//(2).设置请求方法和地址”,
“//get请求的数据直接添加在url的后面 格式是 url?key=value”,
“xhr.open(‘get’, ‘接口url’)”,
“//(3).发送请求”,
“xhr.send()”,
“//(4).注册回调函数”,
“xhr.onload = function() {”,
“\tconsole.log(xhr.responseText)”,
“}”,
],
“description”: “get-原生XMLHTTPRequest实现ajax”
},
“post for XMLHTTPRequest”: {
“prefix”: “ajax2”,
“body”: [
“//(1).实例化ajax对象”,
“let xhr = new XMLHttpRequest()”,
“//(2).设置请求方法和地址”,
“xhr.open(‘post’, 'KaTeX parse error: Undefined control sequence: \tconsole at position 239: …ion () {", "\̲t̲c̲o̲n̲s̲o̲l̲e̲.log(xhr.respon…(‘提交按钮’).on(‘click’,function(e){”,
“\t//禁用表单默认提交事件”,
“\te.preventDefault()”,
“\t//创建FormData对象:参数是表单dom对象”,
“\tlet fd = new FormData(‘form表单DOM对象’)”,
“\tKaTeX parse error: Undefined control sequence: \t at position 15: .ajax({", "\̲t̲\turl:'',", …$mount(‘#app’)”,
],
“description”: “快速生成路由”
},
“to set baseURL”: {
“prefix”: “base”,
“body”: [
“axios.defaults.baseURL = ‘根地址’”,
],
“description”: “to set baseURL”
},
“to set request”: {
“prefix”: “request”,
“body”: [
“// 添加请求拦截器”,
“axios.interceptors.request.use(function (config) {”,
“// 在发送请求之前做些什么”,
“\treturn config;”,
“}, function (error) {”,
“// 对请求错误做些什么”,
“\treturn Promise.reject(error);”,
“});”
],
“description”: “to set request”
},
“to set response”: {
“prefix”: “response”,
“body”: [
“// 添加响应拦截器”,
“axios.interceptors.response.use(function (response) {”,
“// 在响应之前做些什么”,
“\treturn response;”,
“}, function (error) {”,
“// 对请求错误做些什么”,
“\treturn Promise.reject(error);”,
“});”
],
“description”: “to set response”
},
“Print to vue”: {
“prefix”: “vuec”,
“body”: [
“”,
"

“,
" 御剑乘风来,除魔天地间!$1”,
"
“,
“”,
" “,
“”,
“”
],
“description”: “create a vue template”
},
“Print to vue3-1”: {
“prefix”: “vue3-1”,
“body”: [
“”,
"
”,
" 御剑乘风来,除魔天地间! KaTeX parse error: Expected 'EOF', got '}' at position 259: …vue template" }̲, "Print to v"…ajax”,
“body”: [
“$.ajax({”,
“\turl: ‘’,”,
“\ttype:‘get’,”,
“\tdata:{},”,
“\tsuccess:function(res){”,
“\t\t\t”,
“\t},”,
“})”
]
},
“Print to rcl”: {
“prefix”: “rcl”,
“body”: [
“$2”,
“class Com extends React.Component {”,
“\trender() {”,
“\t\treturn
”,
“\t\t\t御剑乘风来,除魔天地间!$1”,
“\t\t
”,
“\t}”,
“}”
],
“description”: “类组件”
},
“Print to rrcl”: {
“prefix”: “rrcl”,
“body”: [
“import React from ‘react’”,
“$2”,
“class Com extends React.Component {”,
“\trender() {”,
“\t\treturn
”,
“\t\t\t御剑乘风来,除魔天地间!$1”,
“\t\t
”,
“\t}”,
“}”,
“export default Com”
],
“description”: “类组件”
},
“Print to rfun”: {
“prefix”: “rfun”,
“body”: [
“$2”,
“const Func = () => {”,
“\treturn
”,
“\t\t御剑乘风来,除魔天地间!$1”,
”,
“};”,
],
“description”: “函数式组件”
},
“Print to rrfun”: {
“prefix”: “rrfun”,
“body”: [
“import React from ‘react’”,
“$2”,
“const Func = () => {”,
“\treturn
”,
“\t\t御剑乘风来,除魔天地间!$1”,
”,
“};”,
“export default Func”
],
“description”: “函数式组件”
},
“Print to vuex”: {
“prefix”: “vuex”,
“body”: [
“export default {”,
“\tstate () {”,
“\t\treturn {”,
// 文章分类的列表数据
“\t\t\t”,
“\t\t}”,
“\t},”,
“\tmutations: {”,
// 设置分类列表数据
“\t\t\t”,
“\t},”,
“\tactions: {”,
“\t},”,
“\tgetters: {},”,
// 开启命名空间
“\tnamespaced: true”,
“}”,
],
“description”: “函数式组件”
}
}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值