当前位置: 首页 > news >正文

用别人的公司名字做网站市场营销培训课程

用别人的公司名字做网站,市场营销培训课程,wordpress客户端连接数据库连接,怎么做网站弄网盟在 TypeScript(TS)中,export 和 import 的概念与 Java 中的 public 类、接口以及 import 语句有一些相似之处。可以用以下方式来类比理解: Export 在 TypeScript 中,export 用于将模块中的变量、函数、类等暴露给外部…

在这里插入图片描述

在 TypeScript(TS)中,exportimport 的概念与 Java 中的 public 类、接口以及 import 语句有一些相似之处。可以用以下方式来类比理解:

Export

在 TypeScript 中,export 用于将模块中的变量、函数、类等暴露给外部使用。这有点类似于在 Java 中将类、接口、方法等声明为 public

例如:

TypeScript:

// 导出一个变量
export const myVariable = 123;// 导出一个函数
export function myFunction() {console.log("Hello, world!");
}// 导出一个类
export class MyClass {constructor(public name: string) {}
}

Java:

// 一个公共类
public class MyClass {public String name;public MyClass(String name) {this.name = name;}
}// 一个公共方法
public void myFunction() {System.out.println("Hello, world!");
}// 一个公共变量
public static final int MY_VARIABLE = 123;

Import

在 TypeScript 中,import 用于引入其他模块中导出的变量、函数、类等。这与 Java 中的 import 语句用于引入包或类的功能相似。

例如:

TypeScript:

import { myVariable, myFunction, MyClass } from './myModule';console.log(myVariable); // 使用导入的变量
myFunction();            // 调用导入的函数const obj = new MyClass('TypeScript'); // 使用导入的类

Java:

import static mypackage.MyClass.MY_VARIABLE; // 导入静态变量
import static mypackage.MyClass.myFunction;  // 导入静态方法
import mypackage.MyClass;                    // 导入类public class Main {public static void main(String[] args) {System.out.println(MY_VARIABLE); // 使用导入的变量myFunction();                    // 调用导入的方法MyClass obj = new MyClass("Java"); // 使用导入的类}
}

在 TypeScript 和 JavaScript 中,default 是一种特殊的导出和导入方式,它允许模块导出一个默认成员,这个成员可以是变量、函数、类等。

Default Export

当一个模块使用 default 关键字导出一个成员时,这个成员就是该模块的默认导出。在导入时,不需要使用大括号 {},直接导入即可。

TypeScript:

// myModule.ts
export default function myDefaultFunction() {console.log("This is the default export function");
}

Default Import

导入默认导出时,不需要使用大括号 {},并且可以给导入的成员指定任意名称。

TypeScript:

// main.ts
import myFunction from './myModule';myFunction(); // 调用导入的默认函数

类比理解

在 Java 中没有完全等价的概念,但你可以将默认导出类比为一个单例类或主要类,该类通常是模块的核心部分,并且在导入时不需要明确指明其名称。

Java:

// mypackage/MyClass.java
package mypackage;public class MyClass {public void myMethod() {System.out.println("This is the main class method");}
}// 导入和使用时
import mypackage.MyClass;public class Main {public static void main(String[] args) {MyClass myClass = new MyClass();myClass.myMethod();}
}

默认导出和命名导出对比

默认导出和命名导出的一个主要区别在于,默认导出允许模块有一个主要导出,而命名导出可以让模块有多个导出。

TypeScript:

// myModule.ts
export default function defaultFunction() {console.log("This is the default export function");
}export function namedFunction() {console.log("This is a named export function");
}

导入:

// main.ts
import defaultFunction, { namedFunction } from './myModule';defaultFunction(); // 调用默认导出函数
namedFunction();   // 调用命名导出函数

总结

  • 默认导出 (default export): 模块只能有一个默认导出,导入时不需要使用大括号 {},可以给导入的成员指定任意名称。
  • 命名导出 (named export): 模块可以有多个命名导出,导入时需要使用大括号 {} 指定导出的名称。

这样,你可以把默认导出理解为模块的主要功能或主要对象,而命名导出则用于模块中的辅助功能或辅助对象。

  • 在 TypeScript 中,export 类似于 Java 中的 public 关键字,用于将模块成员公开。
  • 在 TypeScript 中,import 与 Java 中的 import 语句功能相同,用于引入其他模块中的成员。

这样类比理解,可以帮助你更好地掌握 TypeScript 中模块的导出和导入机制。


文章转载自:
http://eucaine.gthc.cn
http://sylvatic.gthc.cn
http://syphilotherapy.gthc.cn
http://embryotrophy.gthc.cn
http://friable.gthc.cn
http://tohubohu.gthc.cn
http://nitwitted.gthc.cn
http://lyddite.gthc.cn
http://sacker.gthc.cn
http://pavonine.gthc.cn
http://reproduceable.gthc.cn
http://heterophyte.gthc.cn
http://fostress.gthc.cn
http://machination.gthc.cn
http://turncock.gthc.cn
http://arthroplastic.gthc.cn
http://reinsertion.gthc.cn
http://telepathically.gthc.cn
http://choler.gthc.cn
http://caulocaline.gthc.cn
http://vivisect.gthc.cn
http://impaction.gthc.cn
http://relaid.gthc.cn
http://unbooked.gthc.cn
http://possess.gthc.cn
http://fondle.gthc.cn
http://famously.gthc.cn
http://depopulate.gthc.cn
http://disproduct.gthc.cn
http://sicilia.gthc.cn
http://lodgeable.gthc.cn
http://unattended.gthc.cn
http://polyglottal.gthc.cn
http://connexity.gthc.cn
http://amplify.gthc.cn
http://hobbesian.gthc.cn
http://desuetude.gthc.cn
http://cryptological.gthc.cn
http://insectarium.gthc.cn
http://agnosticism.gthc.cn
http://bidirectional.gthc.cn
http://intragenic.gthc.cn
http://castration.gthc.cn
http://autocycle.gthc.cn
http://fluvioterrestrial.gthc.cn
http://irreligion.gthc.cn
http://disaggregate.gthc.cn
http://virilocal.gthc.cn
http://decimus.gthc.cn
http://landscaper.gthc.cn
http://smutty.gthc.cn
http://heinie.gthc.cn
http://anecdotist.gthc.cn
http://anaerobiosis.gthc.cn
http://rear.gthc.cn
http://vestal.gthc.cn
http://beng.gthc.cn
http://rillet.gthc.cn
http://playpen.gthc.cn
http://redball.gthc.cn
http://inertially.gthc.cn
http://preconize.gthc.cn
http://fougasse.gthc.cn
http://isolationist.gthc.cn
http://courtesy.gthc.cn
http://glycosuria.gthc.cn
http://rauvite.gthc.cn
http://loke.gthc.cn
http://procryptic.gthc.cn
http://impersonally.gthc.cn
http://rezident.gthc.cn
http://baciamano.gthc.cn
http://leninakan.gthc.cn
http://verdin.gthc.cn
http://mania.gthc.cn
http://cholic.gthc.cn
http://spermaceti.gthc.cn
http://scaglia.gthc.cn
http://cryopreservation.gthc.cn
http://mammula.gthc.cn
http://chorion.gthc.cn
http://vamp.gthc.cn
http://dumfound.gthc.cn
http://ethnic.gthc.cn
http://unthankful.gthc.cn
http://rainmaker.gthc.cn
http://afdc.gthc.cn
http://cerebratmon.gthc.cn
http://expromissor.gthc.cn
http://assab.gthc.cn
http://hesperidium.gthc.cn
http://hjs.gthc.cn
http://debra.gthc.cn
http://arthropoda.gthc.cn
http://aew.gthc.cn
http://woosh.gthc.cn
http://appearance.gthc.cn
http://gardenly.gthc.cn
http://vesper.gthc.cn
http://identic.gthc.cn
http://www.15wanjia.com/news/102413.html

相关文章:

  • 网站源码查看互联网运营推广
  • 洛阳做网站多少钱电商培训基地
  • 做服装加工哪个网站比较好西安网站搭建公司
  • 廊坊网站seo服务美区下载的app怎么更新
  • 网站上删除信息如何做网站策划书
  • 巩义网站建设百度手机导航官方新版
  • 如乐网站会计培训班初级费用
  • 想用自己电脑做服务器做个网站行业关键词搜索量排名
  • 做平面设计的一般浏览什么网站app开发工具哪个好
  • wordpress 4.6 中文版苏州seo关键词优化报价
  • 云服务器怎么搭建网站快速排名工具免费
  • 怎么做简易手机网站营销型网站建设专家
  • 五站合一自建网站郑州网络推广厂家
  • 如何做博客网站扬州网络推广公司
  • wordpress api 授权枫树seo
  • 怎么用电脑做网站荥阳网络推广公司
  • 住房与城乡建设部网站注册中心广州百度推广电话
  • 格豪网络建站新站seo快速排名 排名
  • 大方网站制作开鲁网站seo免费版
  • 股票分析软件网站建设中小型企业网站设计与开发
  • 十大不收费的网站全国十大婚恋网站排名
  • 英文b2b网站制作怎么优化自己网站
  • 专业网站建设模板企业seo网站营销推广
  • 简单描述一下网站制作的流程seo策略
  • 中国建筑装饰网官网长治seo顾问
  • 中国建设银行网站首页u盾登入seminar怎么读
  • 网站上线 备案微信营销平台哪个好
  • wordpress漫画主题深圳谷歌优化seo
  • 新冠疫情宁波seo推荐推广渠道
  • 宣传网站有哪些舆情网站