根据我的理解,ES6和ES2015是一回事。但是在打字稿中,这两件事有2种类型声明:lib.es6.d.ts
和lib.es2015.d.ts
。有什么区别?我应该使用哪一个?
答案 0 :(得分:3)
ES6和ES2015是同义词。 TypeScript using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;
public partial class ExportGridView : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
GridView1.DataSource = BindData();
GridView1.DataBind();
}
}
private string ConnectionString
{
get { return @"Server=localhost;Database=Northwind;
Trusted_Connection=true"; }
}
private DataSet BindData()
{
// make the query
string query = "SELECT * FROM Categories";
SqlConnection myConnection = new SqlConnection(ConnectionString);
SqlDataAdapter ad = new SqlDataAdapter(query, myConnection);
DataSet ds = new DataSet();
ad.Fill(ds, "Categories");
return ds;
}
protected void Button1_Click(object sender, EventArgs e)
{
Response.Clear();
Response.AddHeader("content-disposition", "attachment;
filename=FileName.xls");
Response.Charset = "";
// If you want the option to open the Excel file without saving than
// comment out the line below
// Response.Cache.SetCacheability(HttpCacheability.NoCache);
Response.ContentType = "application/vnd.xls";
System.IO.StringWriter stringWrite = new System.IO.StringWriter();
System.Web.UI.HtmlTextWriter htmlWrite =
new HtmlTextWriter(stringWrite);
GridView1.RenderControl(htmlWrite);
Response.Write(stringWrite.ToString());
Response.End();
}
public override void VerifyRenderingInServerForm(Control control)
{
// Confirms that an HtmlForm control is rendered for the
specified ASP.NET server control at run time.
}
//resource : https://www.daniweb.com/programming/web-development/threads/360606/how-to-export-data-from-gridview-to-excel-in-asp-net
}
和target
具有相同的名称,在TypeScript中的行为类似 - 而且它们都是。
lib
和lib.d.ts
是累积库文件。它们是generated from other libraries:
此目录中的文件用于生成lib.d.ts和lib.es6.d.ts。
它们包括各自的规范库以及lib.es6.d.ts
。
DOM
和lib.es6.d.ts
之间的区别在于,前者包含在默认情况下,lib.es2015.d.ts
设置为target
时未指定ES6
,而后者与lib
设置为lib
一起使用。即ES6
与--target ES6
相同。
--target ES6 --lib ES6,DOM,DOM.Iterable,Scripthost
库是细粒度的,因此在必要时ES2015
或ES6
可以替换为a subset of features:ES2015
等。