vscode中的ajax片段,
分享于 点击 17615 次 点评:156
vscode中的ajax片段,
1.首先打开vscode找到右下角的齿轮样子图标
2.点击打开 打开用户代码片段
3.会出现一个框 搜索php
4.删除里面的内容复制下面的代码
{
// 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:
"express基础代码": {
"prefix": "express",
"body": [
"const express = require('express');",
"const app = express();",
"$1",
"app.listen(3000,()=>{",
"\tconsole.log('正在监听端口3000,http://127.0.0.1:3000');",
"})"
],
"description": "express基础代码"
},
"console.log": {
"prefix": "clg",
"body": [
"console.log($1);"
]
},
"ajax快捷方式": {
"prefix": "ajax",
"body": [
"//其他参数:beforeSend在发送之前可以使用return false取消,timeout超时时间,error,async同步还是异步",
"$.ajax({",
"\ttype:'$1',//get或post",
"\turl:'$2',//请求的地址",
"\tdata:{},//如果不需要传,则注释掉 请求的参数,a=1&b=2或{a:1,b:2}或者jq中的serialize方法,或者formData收集",
"\tdataType:'json',//text,json,xml,jsonp",
"\tsuccess:function(res){//成功的回调函数",
"\t\tconsole.log(res)",
"\t}",
"})"
]
}
}
最后只要在页面输入ajax敲回车键就好
相关文章
- 暂无相关文章
用户点评