1.TS声明
declare var ant:string // 声明字符串
declare const min:1 // 声明常量 min = 1
declare function func(str:string):string // 声明函数,传递返回都是string
declare class Person {
static maxAge: number //静态变量
static getMaxAge(): number //静态方法
constructor(name: string, age: number) //构造函数
getName(id: number): string
} // 声明类
declare namespace space {
function func(str: string): string;
let num: number;
} // 声明命名空间,里面有一个函数成员和变量成员
declare module "abcde" {
export let a: number
export function b(): number
export namespace c{
let cd: string
}
} //模块化
let a = require('adced')//调用
a.b();
2.jQuery 是一个 JavaScript 库,jQuery 极大地简化了 JavaScript 编程。
3.前端与后端交互方式–AJax( Asynchronous JavaScript and XML(异步的 JavaScript 和 XML))
$.ajax({
cache: true,
type: "POST",
url:‘表单提交的url地址’,
data:$('#myformid').serialize(),// 序列化form表单数据,后台解析需要反序列化
async: false,//false表示同步,true表示异步
error: function(request) {
alert("请求失败");
},
success: function(data) {
console.log(data);//data为服务器处理后返回的数据
alert("请求成功");
}
});
转自:https://www.cnblogs.com/liutianzeng/p/10828615.html