{"id":4839,"date":"2024-06-28T19:59:41","date_gmt":"2024-06-28T11:59:41","guid":{"rendered":"https:\/\/www.ddddrama.top\/?p=4839"},"modified":"2024-07-25T14:31:59","modified_gmt":"2024-07-25T06:31:59","slug":"arkts","status":"publish","type":"post","link":"https:\/\/www.ddddrama.top\/index.php\/2024\/06\/28\/arkts\/","title":{"rendered":"ArkTS"},"content":{"rendered":"<blockquote>\n<p>\u53c2\u8003\u6587\u6863\uff1a<a href=\"https:\/\/developer.huawei.com\/consumer\/cn\/doc\/harmonyos-guides-V5\/arkts-get-started-V5\">\u521d\u8bc6ArkTS\u8bed\u8a00-\u5b66\u4e60ArkTS\u8bed\u8a00-\u57fa\u7840\u5165\u95e8 | \u534e\u4e3a\u5f00\u53d1\u8005\u8054\u76df (huawei.com)<\/a><\/p>\n<\/blockquote>\n<h2>\u73af\u5883<\/h2>\n<p>\u5b89\u88c5\u7248\u672c\uff1a<a href=\"https:\/\/developer.huawei.com\/consumer\/cn\/doc\/harmonyos-releases-V5\/deveco-studio-new-features-V5\">DevEco Studio NEXT Developer Beta2 (2024\/07\/20)<\/a><\/p>\n<h3>\u521b\u5efa\u5de5\u7a0b<\/h3>\n<p>\u6587\u4ef6&gt;\u65b0\u5efa\u9879\u76ee&gt;Application&gt;Empty Ability<\/p>\n<h4>Hello World<\/h4>\n<pre><code class=\"language-typescript\">\/\/ \u5bfc\u5165\u9875\u9762\u8def\u7531\u6a21\u5757\nimport { router } from &#039;@kit.ArkUI&#039;;\nimport { BusinessError } from &#039;@kit.BasicServicesKit&#039;;\n\n@Entry\n@Component\nstruct Index {\n  @State message: string = &#039;Hello World&#039;\n\n  build() {\n    Row() {\n      Column() {\n        Text(this.message)\n          .fontSize(50)\n          .fontWeight(FontWeight.Bold)\n        \/\/ \u6dfb\u52a0\u6309\u94ae\uff0c\u4ee5\u54cd\u5e94\u7528\u6237\u70b9\u51fb\n        Button() {\n          Text(&#039;Next&#039;)\n            .fontSize(30)\n            .fontWeight(FontWeight.Bold)\n        }\n        .type(ButtonType.Capsule)\n        .margin({\n          top: 20\n        })\n        .backgroundColor(&#039;#0D9FFB&#039;)\n        .width(&#039;40%&#039;)\n        .height(&#039;5%&#039;)\n        \/\/ \u8df3\u8f6c\u6309\u94ae\u7ed1\u5b9aonClick\u4e8b\u4ef6\uff0c\u70b9\u51fb\u65f6\u8df3\u8f6c\u5230\u7b2c\u4e8c\u9875\n        .onClick(() =&gt; {\n          console.info(`Succeeded in clicking the &#039;Next&#039; button.`)\n          \/\/ \u8df3\u8f6c\u5230\u7b2c\u4e8c\u9875\n          router.pushUrl({ url: &#039;pages\/Second&#039; }).then(() =&gt; {\n            console.info(&#039;Succeeded in jumping to the second page.&#039;)\n\n          }).catch((err: BusinessError) =&gt; {\n            console.error(`Failed to jump to the second page. Code is ${err.code}, message is ${err.message}`)\n          })\n        })\n      }\n      .width(&#039;100%&#039;)\n    }\n    .height(&#039;100%&#039;)\n  }\n}<\/code><\/pre>\n<h5>\u6dfb\u52a0\u7b2c\u4e8c\u4e2a\u9875\u9762<\/h5>\n<p>\u914d\u7f6e\u8def\u7531entry \/ src \/ main \/ resources \/ base \/ profile \/ main_pages.json\uff1a<\/p>\n<pre><code class=\"language-json\">{\n  &quot;src&quot;: [\n    &quot;pages\/Index&quot;,\n    &quot;pages\/Second&quot;\n  ]\n}<\/code><\/pre>\n<p>\u7b2c\u4e8c\u4e2a\u9875\u9762\uff1a<\/p>\n<pre><code class=\"language-typescript\">\/\/ Second.ets\n\/\/ \u5bfc\u5165\u9875\u9762\u8def\u7531\u6a21\u5757\nimport { router } from &#039;@kit.ArkUI&#039;;\nimport { BusinessError } from &#039;@kit.BasicServicesKit&#039;;\n\n@Entry\n@Component\nstruct Second {\n  @State message: string = &#039;Hi there&#039;\n\n  build() {\n    Row() {\n      Column() {\n        Text(this.message)\n          .fontSize(50)\n          .fontWeight(FontWeight.Bold)\n        Button() {\n          Text(&#039;Back&#039;)\n            .fontSize(25)\n            .fontWeight(FontWeight.Bold)\n        }\n        .type(ButtonType.Capsule)\n        .margin({\n          top: 20\n        })\n        .backgroundColor(&#039;#0D9FFB&#039;)\n        .width(&#039;40%&#039;)\n        .height(&#039;5%&#039;)\n        \/\/ \u8fd4\u56de\u6309\u94ae\u7ed1\u5b9aonClick\u4e8b\u4ef6\uff0c\u70b9\u51fb\u6309\u94ae\u65f6\u8fd4\u56de\u5230\u7b2c\u4e00\u9875\n        .onClick(() =&gt; {\n          console.info(`Succeeded in clicking the &#039;Back&#039; button.`)\n          try {\n            \/\/ \u8fd4\u56de\u7b2c\u4e00\u9875\n            router.back()\n            console.info(&#039;Succeeded in returning to the first page.&#039;)\n          } catch (err) {\n            let code = (err as BusinessError).code; \n            let message = (err as BusinessError).message; \n            console.error(`Failed to return to the first page. Code is ${code}, message is ${message}`)\n          }\n        })\n      }\n      .width(&#039;100%&#039;)\n    }\n    .height(&#039;100%&#039;)\n  }\n}<\/code><\/pre>\n<h5>\u9875\u9762\u8df3\u8f6c<\/h5>\n<p>\u5728 Index.ets \u5bfc\u5165\u9875\u9762\u8def\u7531\u6a21\u5757 router\uff1a<\/p>\n<pre><code class=\"language-typescript\">\/\/ Index.ets\n\/\/ \u5bfc\u5165\u9875\u9762\u8def\u7531\u6a21\u5757\nimport { router } from &#039;@kit.ArkUI&#039;;\nimport { BusinessError } from &#039;@kit.BasicServicesKit&#039;;<\/code><\/pre>\n<p>\u5c06 Next \u6309\u94ae\u7ed1\u5b9a onClick \u4e8b\u4ef6\uff1a<\/p>\n<pre><code class=\"language-typescript\">\/\/ Index.ets\n\/\/ ...\n        \/\/ \u6dfb\u52a0\u6309\u94ae\uff0c\u4ee5\u54cd\u5e94\u7528\u6237\u70b9\u51fb\n        Button() {\n          Text(&#039;Next&#039;)\n            .fontSize(30)\n            .fontWeight(FontWeight.Bold)\n        }\n        .type(ButtonType.Capsule)\n        .margin({\n          top: 20\n        })\n        .backgroundColor(&#039;#0D9FFB&#039;)\n        .width(&#039;40%&#039;)\n        .height(&#039;5%&#039;)\n        \/\/ \u8df3\u8f6c\u6309\u94ae\u7ed1\u5b9aonClick\u4e8b\u4ef6\uff0c\u70b9\u51fb\u65f6\u8df3\u8f6c\u5230\u7b2c\u4e8c\u9875\n        .onClick(() =&gt; {\n          console.info(`Succeeded in clicking the &#039;Next&#039; button.`)\n          \/\/ \u8df3\u8f6c\u5230\u7b2c\u4e8c\u9875\n          router.pushUrl({ url: &#039;pages\/Second&#039; }).then(() =&gt; {\n            console.info(&#039;Succeeded in jumping to the second page.&#039;)\n\n          }).catch((err: BusinessError) =&gt; {\n            console.error(`Failed to jump to the second page. Code is ${err.code}, message is ${err.message}`)\n          })\n        })<\/code><\/pre>\n<p>Second.ets \u7684 back \u6309\u94ae\u7c7b\u4f3c\u3002<\/p>\n<h5>\u6548\u679c<\/h5>\n<p><img decoding=\"async\" src=\"https:\/\/www.ddddrama.top\/wp-content\/uploads\/2024\/06\/image-1719656423596.20240625162806.65988528664452518825772083342308500012310000002800371F093F8FC0DAF21E2460C9723548A6A2E4BD5BF52DCB36CDD093ECD9C827BB-300x279.png\" alt=\"\" \/><\/p>\n<h2>ArkTS \u57fa\u672c\u7ec4\u6210<\/h2>\n<p><img decoding=\"async\" src=\"https:\/\/www.ddddrama.top\/wp-content\/uploads\/2024\/06\/image-1719656450657.20240625162824.162209230833480391267963974638315000123100000028001B66B64F0E3E4D032EDBFF2D7DD79ECEEEB9F58F98592C967EE002DCC3B60268-300x258.png\" alt=\"\" \/><\/p>\n<h2>\u57fa\u7840<\/h2>\n<h3>\u58f0\u660e<\/h3>\n<h4>\u53d8\u91cf<\/h4>\n<p>\u5173\u952e\u5b57 let<\/p>\n<pre><code class=\"language-typescript\">let hi: string = &#039;hello&#039;;\nhi = &#039;hello, world&#039;;<\/code><\/pre>\n<h4>\u5e38\u91cf<\/h4>\n<p>\u5173\u952e\u5b57 const<\/p>\n<pre><code class=\"language-typescript\">const hi: string = &#039;hello&#039;;<\/code><\/pre>\n<h4>\u81ea\u52a8\u7c7b\u578b\u63a8\u65ad<\/h4>\n<p>\u6709\u521d\u59cb\u503c\u65f6\uff0c\u4e0d\u7528\u663e\u793a\u6307\u5b9a\u7c7b\u578b<\/p>\n<pre><code class=\"language-typescript\">let hi = &#039;hello&#039;;<\/code><\/pre>\n<h3>\u7c7b\u578b<\/h3>\n<h4>Number \u7c7b\u578b<\/h4>\n<p>\u5305\u62ec\u6574\u6570\u548c\u6d6e\u70b9\u6570<\/p>\n<pre><code class=\"language-typescript\">let n1 = 3.14;\nlet n2 = 3.141592;\nlet n3 = .5;\nlet n4 = 1e10;\n\/\/ \u9636\u4e58\nfunction factorial(n: number): number {\n  if (n &lt;= 1) {\n    return 1;\n  }\n  return n * factorial(n - 1);\n}<\/code><\/pre>\n<h4>Boolean \u7c7b\u578b<\/h4>\n<p>true \u548c false<\/p>\n<pre><code class=\"language-typescript\">let isDone: boolean = false;\n\n\/\/ ...\n\nif (isDone) {\n  console.log (&#039;Done!&#039;);\n}<\/code><\/pre>\n<h4>String \u7c7b\u578b<\/h4>\n<p>\uff08&#8217;\uff09\u6216\uff08&quot;\uff09\u6216\uff08`\uff09<\/p>\n<pre><code class=\"language-typescript\">let s1 = &#039;Hello, world!\\n&#039;;\nlet s2 = &#039;this is a string&#039;;\nlet a = &#039;Success&#039;;\nlet s3 = `The result is ${a}`;<\/code><\/pre>\n<h4>Void \u7c7b\u578b<\/h4>\n<p>\u7528\u4e8e\u6307\u5b9a\u51fd\u6570\u6ca1\u6709\u8fd4\u56de\u503c<\/p>\n<pre><code class=\"language-typescript\">\/\/ \u5b9a\u4e49\u4e00\u4e2a\u8fd4\u56de\u7c7b\u578b\u4e3a void \u7684\u51fd\u6570\nfunction logMessage(message: string): void {\n    console.info(message);\n}<\/code><\/pre>\n<h4>Object \u7c7b\u578b<\/h4>\n<p>\u5bf9\u8c61<\/p>\n<h4>Array \u7c7b\u578b<\/h4>\n<p>\u6570\u7ec4<\/p>\n<pre><code class=\"language-typescript\">let names: string[] = [&#039;Alice&#039;, &#039;Bob&#039;, &#039;Carol&#039;];<\/code><\/pre>\n<h4>Enum \u7c7b\u578b | \u679a\u4e3e\u7c7b\u578b<\/h4>\n<pre><code class=\"language-typescript\">enum ColorSet { White = 0xFF, Grey = 0x7F, Black = 0x00 }\nlet c: ColorSet = ColorSet.Black;<\/code><\/pre>\n<h4>Union \u7c7b\u578b<\/h4>\n<p>\u8054\u5408\u7c7b\u578b\uff0c\u7531\u591a\u4e2a\u7c7b\u578b\u7ec4\u5408\u6210\u7684\u5f15\u7528\u7c7b\u578b<\/p>\n<pre><code class=\"language-typescript\">class Cat { sleep () {}; meow () {} }\nclass Dog { sleep () {}; bark () {} }\nclass Frog { sleep () {}; leap () {} }\n\ntype Animal = Cat | Dog | Frog | number\n\nlet animal: Animal = new Frog();\nif (animal instanceof Frog) {\n  let frog: Frog = animal as Frog; \/\/ animal\u5728\u8fd9\u91cc\u662fFrog\u7c7b\u578b\n  animal.leap();\n  frog.leap();\n  \/\/ \u7ed3\u679c\uff1a\u9752\u86d9\u8df3\u4e86\u4e24\u6b21\n}\n\nanimal.sleep (); \/\/ \u4efb\u4f55\u52a8\u7269\u90fd\u53ef\u4ee5\u7761\u89c9<\/code><\/pre>\n<h4>Aliases \u7c7b\u578b<\/h4>\n<p>\u4e3a\u533f\u540d\u7c7b\u578b\uff08\u6570\u7ec4\u3001\u51fd\u6570\u3001\u5bf9\u8c61\u5b57\u9762\u91cf\u6216\u8054\u5408\u7c7b\u578b\uff09\u63d0\u4f9b\u540d\u79f0\uff0c\u6216\u4e3a\u5df2\u6709\u7c7b\u578b\u63d0\u4f9b\u66ff\u4ee3\u540d\u79f0\u3002<\/p>\n<pre><code class=\"language-typescript\">type Matrix = number[][];\ntype Handler = (s: string, no: number) =&gt; string;\ntype Predicate &lt;T&gt; = (x: T) =&gt; Boolean;\ntype NullableObject = Object | null;<\/code><\/pre>\n<h3>\u8fd0\u7b97\u7b26<\/h3>\n<h4>\u8d4b\u503c<\/h4>\n<p>=<\/p>\n<h5>\u590d\u5408\u8d4b\u503c<\/h5>\n<p>+=\u3001-=\u3001*=\u3001\/=\u3001%=\u3001&lt;&lt;=\u3001&gt;&gt;=\u3001&gt;&gt;&gt;=\u3001&amp;=\u3001|=\u3001^=<\/p>\n<h4>\u6bd4\u8f83<\/h4>\n<p>==\u3001!=\u3001&gt;\u3001&gt;=\u3001&lt;\u3001&lt;=<\/p>\n<h4>\u7b97\u672f<\/h4>\n<h5>\u4e00\u5143<\/h5>\n<p>-\u3001+\u3001&#8211;\u3001++<\/p>\n<h5>\u4e8c\u5143<\/h5>\n<p>-\u3001+\u3001*\u3001\/\u3001%<\/p>\n<h4>\u4f4d\u8fd0\u7b97\u7b26<\/h4>\n<table>\n<thead>\n<tr>\n<th>\u8fd0\u7b97\u7b26<\/th>\n<th>\u8bf4\u660e<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>a &amp; b<\/td>\n<td>\u6309\u4f4d\u4e0e\uff1a\u5982\u679c\u4e24\u4e2a\u64cd\u4f5c\u6570\u7684\u5bf9\u5e94\u4f4d\u90fd\u4e3a1\uff0c\u5219\u5c06\u8fd9\u4e2a\u4f4d\u8bbe\u7f6e\u4e3a1\uff0c\u5426\u5219\u8bbe\u7f6e\u4e3a0\u3002<\/td>\n<\/tr>\n<tr>\n<td>a | b<\/td>\n<td>\u6309\u4f4d\u6216\uff1a\u5982\u679c\u4e24\u4e2a\u64cd\u4f5c\u6570\u7684\u76f8\u5e94\u4f4d\u4e2d\u81f3\u5c11\u6709\u4e00\u4e2a\u4e3a1\uff0c\u5219\u5c06\u8fd9\u4e2a\u4f4d\u8bbe\u7f6e\u4e3a1\uff0c\u5426\u5219\u8bbe\u7f6e\u4e3a0\u3002<\/td>\n<\/tr>\n<tr>\n<td>a ^ b<\/td>\n<td>\u6309\u4f4d\u5f02\u6216\uff1a\u5982\u679c\u4e24\u4e2a\u64cd\u4f5c\u6570\u7684\u5bf9\u5e94\u4f4d\u4e0d\u540c\uff0c\u5219\u5c06\u8fd9\u4e2a\u4f4d\u8bbe\u7f6e\u4e3a1\uff0c\u5426\u5219\u8bbe\u7f6e\u4e3a0\u3002<\/td>\n<\/tr>\n<tr>\n<td>~ a<\/td>\n<td>\u6309\u4f4d\u975e\uff1a\u53cd\u8f6c\u64cd\u4f5c\u6570\u7684\u4f4d\u3002<\/td>\n<\/tr>\n<tr>\n<td>a &lt;&lt; b<\/td>\n<td>\u5de6\u79fb\uff1a\u5c06a\u7684\u4e8c\u8fdb\u5236\u8868\u793a\u5411\u5de6\u79fbb\u4f4d\u3002<\/td>\n<\/tr>\n<tr>\n<td>a &gt;&gt; b<\/td>\n<td>\u7b97\u672f\u53f3\u79fb\uff1a\u5c06a\u7684\u4e8c\u8fdb\u5236\u8868\u793a\u5411\u53f3\u79fbb\u4f4d\uff0c\u5e26\u7b26\u53f7\u6269\u5c55\u3002<\/td>\n<\/tr>\n<tr>\n<td>a &gt;&gt;&gt; b<\/td>\n<td>\u903b\u8f91\u53f3\u79fb\uff1a\u5c06a\u7684\u4e8c\u8fdb\u5236\u8868\u793a\u5411\u53f3\u79fbb\u4f4d\uff0c\u5de6\u8fb9\u88650\u3002<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h4>\u903b\u8f91\u8fd0\u7b97\u7b26<\/h4>\n<p>&amp;&amp;\u3001|| \u3001\uff01<\/p>\n<h3>\u8bed\u53e5<\/h3>\n<h4>If \u8bed\u53e5<\/h4>\n<pre><code class=\"language-typescript\">if (condition1) {\n  \/\/ \u8bed\u53e51\n} else if (condition2) {\n  \/\/ \u8bed\u53e52\n} else {\n  \/\/ else\u8bed\u53e5\n}<\/code><\/pre>\n<h4>Switch \u8bed\u53e5<\/h4>\n<pre><code class=\"language-typescript\">switch (expression) {\n  case label1: \/\/ \u5982\u679clabel1\u5339\u914d\uff0c\u5219\u6267\u884c\n    \/\/ ...\n    \/\/ \u8bed\u53e51\n    \/\/ ...\n    break; \/\/ \u8df3\u51fa switch\n  case label2:\n  case label3: \/\/ \u5982\u679clabel2\u6216label3\u5339\u914d\uff0c\u5219\u6267\u884c\n    \/\/ ...\n    \/\/ \u8bed\u53e52, \u8bed\u53e53\n    \/\/ ...\n    break; \/\/ \u53ef\u7701\u7565\n  default:\n    \/\/ \u9ed8\u8ba4\u8bed\u53e5\n}<\/code><\/pre>\n<h4>\u6761\u4ef6\u8868\u8fbe\u5f0f<\/h4>\n<pre><code class=\"language-typescript\">\/\/ \u771f\u4e3a 1 \uff0c\u5047\u4e3a 2\ncondition ? expression1 : expression2<\/code><\/pre>\n<h4>For \u8bed\u53e5<\/h4>\n<pre><code class=\"language-typescript\">let sum = 0;\nfor (let i = 0; i &lt; 10; i += 2) {\n  sum += i;\n}<\/code><\/pre>\n<h5>For &#8211; of \u8bed\u53e5<\/h5>\n<p>\u7528\u4e8e\u904d\u5386\u6570\u7ec4\u6216\u5b57\u7b26\u4e32<\/p>\n<pre><code class=\"language-typescript\">for (let char of &#039;a string object&#039;) {\n  \/\/ \u8bed\u53e5\n}<\/code><\/pre>\n<h4>While \u8bed\u53e5<\/h4>\n<pre><code class=\"language-typescript\">let n = 0;\nlet x = 0;\nwhile (n &lt; 3) {\n  n++;\n  x += n;\n}<\/code><\/pre>\n<h5>Do-while \u8bed\u53e5<\/h5>\n<pre><code class=\"language-typescript\">let i = 0;\ndo {\n  i += 1;\n} while (i &lt; 10)<\/code><\/pre>\n<h4>Break \u8bed\u53e5<\/h4>\n<p>\u7ec8\u6b62<\/p>\n<h4>Continue\u8bed\u53e5<\/h4>\n<p>\u505c\u6b62\u5f53\u524d\u5faa\u73af\u8fed\u4ee3\uff0c\u5e76\u5c06\u63a7\u5236\u4f20\u9012\u7ed9\u4e0b\u4e00\u4e2a\u8fed\u4ee3<\/p>\n<h4>Throw \u548c Try\u8bed\u53e5<\/h4>\n<p>throw \u8bed\u53e5\u7528\u4e8e\u629b\u51fa\u5f02\u5e38\u6216\u9519\u8bef<\/p>\n<pre><code class=\"language-typescript\">throw new Error(&#039;this error&#039;)<\/code><\/pre>\n<p>try\u8bed\u53e5\u7528\u4e8e\u6355\u83b7\u548c\u5904\u7406\u5f02\u5e38\u6216\u9519\u8bef<\/p>\n<pre><code class=\"language-typescript\">try {\n  \/\/ \u53ef\u80fd\u53d1\u751f\u5f02\u5e38\u7684\u8bed\u53e5\u5757\n} catch (e) {\n  \/\/ \u5f02\u5e38\u5904\u7406\n} finally {\n  \/\/ \u8bed\u53e5    \n}<\/code><\/pre>\n<h2>\u51fd\u6570<\/h2>\n<h3>\u51fd\u6570\u58f0\u660e<\/h3>\n<pre><code class=\"language-typescript\">function add(x: string, y: string): string {\n  let z: string = `${x} ${y}`;\n  return z;\n}<\/code><\/pre>\n<h3>\u53ef\u9009\u53c2\u6570 | name?: Type<\/h3>\n<p>\u8c03\u7528\u51fd\u6570\u65f6\u53ef\u7701\u7565\u7684\u53c2\u6570<\/p>\n<p>\u53ef\u4e3a\u53ef\u9009\u53c2\u6570\u8bbe\u7f6e\u53c2\u6570\u9ed8\u8ba4\u503c<\/p>\n<pre><code class=\"language-typescript\">function multiply(n: number, coeff: number = 2): number {\n  return n * coeff;\n}\nmultiply(2);  \/\/ \u8fd4\u56de2*2\nmultiply(2, 3); \/\/ \u8fd4\u56de2*3<\/code><\/pre>\n<h3>Rest \u53c2\u6570<\/h3>\n<p>\u7528\u5728\u51fd\u6570\u7684\u6700\u540e\u4e00\u4e2a\u53c2\u6570\uff0c\u5141\u8bb8\u51fd\u6570\u6216\u65b9\u6cd5\u63a5\u53d7\u4efb\u610f\u6570\u91cf\u7684\u5b9e\u53c2<\/p>\n<pre><code class=\"language-typescript\">function sum(...numbers: number[]): number {\n  let res = 0;\n  for (let n of numbers)\n    res += n;\n  return res;\n}\n\nsum() \/\/ \u8fd4\u56de0\nsum(1, 2, 3) \/\/ \u8fd4\u56de6<\/code><\/pre>\n<h3>\u8fd4\u56de\u7c7b\u578b<\/h3>\n<p>\u53ef\u4ee5\u663e\u793a\u6307\u5b9a\uff0c\u53ef\u63a8\u65ad<\/p>\n<pre><code class=\"language-typescript\">\/\/ \u663e\u5f0f\u6307\u5b9a\u8fd4\u56de\u7c7b\u578b\nfunction foo(): string { return &#039;foo&#039;; }\n\n\/\/ \u63a8\u65ad\u8fd4\u56de\u7c7b\u578b\u4e3astring\nfunction goo() { return &#039;goo&#039;; }<\/code><\/pre>\n<h3>\u51fd\u6570\u7684\u4f5c\u7528\u57df<\/h3>\n<p>\u51fd\u6570\u4e2d\u5b9a\u4e49\u7684\u53d8\u91cf\u548c\u5176\u4ed6\u5b9e\u4f8b\u4ec5\u53ef\u4ee5\u5728\u51fd\u6570\u5185\u90e8\u8bbf\u95ee\uff0c\u4e0d\u80fd\u4ece\u5916\u90e8\u8bbf\u95ee\u3002<\/p>\n<p>\u5982\u679c\u51fd\u6570\u4e2d\u5b9a\u4e49\u7684\u53d8\u91cf\u4e0e\u5916\u90e8\u4f5c\u7528\u57df\u4e2d\u5df2\u6709\u5b9e\u4f8b\u540c\u540d\uff0c\u5219\u51fd\u6570\u5185\u7684\u5c40\u90e8\u53d8\u91cf\u5b9a\u4e49\u5c06\u8986\u76d6\u5916\u90e8\u5b9a\u4e49\u3002<\/p>\n<h3>\u51fd\u6570\u7c7b\u578b<\/h3>\n<p>\u51fd\u6570\u7c7b\u578b\u901a\u5e38\u7528\u4e8e\u5b9a\u4e49\u56de\u8c03\uff1a<\/p>\n<pre><code class=\"language-typescript\">type trigFunc = (x: number) =&gt; number \/\/ \u8fd9\u662f\u4e00\u4e2a\u51fd\u6570\u7c7b\u578b\n\nfunction do_action(f: trigFunc) {\n   f(3.141592653589); \/\/ \u8c03\u7528\u51fd\u6570\n}\n\/\/ \u5c06\u51fd\u6570\u4f5c\u4e3a\u53c2\u6570\u4f20\u5165, \u76f8\u5f53\u4e8e Math.sin(3.141592653589)\ndo_action(Math.sin); <\/code><\/pre>\n<h3>\u7bad\u5934\u51fd\u6570<\/h3>\n<pre><code class=\"language-typescript\">\/\/ \u8fd4\u56de\u7c7b\u578b\u53ef\u7701\u7565\nlet sum = (x: number, y: number): number =&gt; {\n  return x + y;\n}\n\/\/ \u7b49\u4ef7\nlet sum1 = (x: number, y: number) =&gt; { return x + y; }\nlet sum2 = (x: number, y: number) =&gt; x + y<\/code><\/pre>\n<h3>\u95ed\u5305<\/h3>\n<pre><code class=\"language-typescript\">\/\/ \u5916\u90e8\u51fd\u6570, \u5916\u90e8\u53c2\u6570\nfunction outerFunction(outerVariable: string) {\n    \/\/ \u8fd4\u56de\u5185\u90e8\u51fd\u6570, \u4e14\u8be5\u5185\u90e8\u51fd\u6570\u4fdd\u6301\u4e86\u5bf9\u5916\u90e8\u53c2\u6570\u3001\u5185\u90e8\u53c2\u6570\u7684\u5f15\u7528\n    return function innerFunction(innerVariable: string) {\n        console.log(&#039;Outer Variable: &#039; + outerVariable);\n        console.log(&#039;Inner Variable: &#039; + innerVariable);\n    }\n}\n\n\/\/ \u6267\u884c\u5916\u90e8\u51fd\u6570 outerFunction()\n\/\/ \u7136\u540e newFunction \u5bf9\u5176\u8fd4\u56de\u7684 innerFunction() \u5b9e\u4f8b\u5f15\u7528\n\/\/ \u540c\u65f6\u7ef4\u6301 innerFunction() \u5b9e\u4f8b\u7684\u73af\u5883\u5f15\u7528, \u5305\u62ec &#039;outside&#039;\nconst newFunction = outerFunction(&#039;outside&#039;);\nnewFunction(&#039;inside&#039;);<\/code><\/pre>\n<p>\u8ba1\u6570\u5668<\/p>\n<pre><code class=\"language-typescript\">\/\/ \u5916\u90e8\u51fd\u6570\nfunction createCounter() {\n    let count = 0;\n    return function() {\n        count++;\n        return count;\n    }\n}\n\n\/\/ counter \u7ef4\u6301\u4e86\u5bf9 count \u7684\u5f15\u7528\nconst counter = createCounter();\nconsole.log(counter()); \/\/ \u8f93\u51fa: 1\nconsole.log(counter()); \/\/ \u8f93\u51fa: 2\nconsole.log(counter()); \/\/ \u8f93\u51fa: 3<\/code><\/pre>\n<h3>\u51fd\u6570\u91cd\u8f7d<\/h3>\n<pre><code class=\"language-typescript\">\/\/ \u5b9a\u4e49\u91cd\u8f7d\u7b7e\u540d\nfunction foo(x: number): void;\nfunction foo(x: string): void;\n\/\/ \u5b9a\u4e49\u5b9e\u73b0\u7b7e\u540d\nfunction foo(x: number | string): void {\n  if (typeof x === &#039;number&#039;) {\n    console.log(x.toString());\n  }else {\n    console.log(x)\n  }\n}\nfoo(123);     \/\/ \u4f7f\u7528\u7b2c\u4e00\u4e2a\u5b9a\u4e49\nfoo(&#039;aa&#039;);    \/\/ \u4f7f\u7528\u7b2c\u4e8c\u4e2a\u5b9a\u4e49<\/code><\/pre>\n<h2>\u7c7b<\/h2>\n<p>\u7c7b\u58f0\u660e\u5f15\u5165\u4e00\u4e2a\u65b0\u7c7b\u578b\uff0c\u5e76\u5b9a\u4e49\u5176\u5b57\u6bb5\u3001\u65b9\u6cd5\u548c\u6784\u9020\u51fd\u6570\u3002<\/p>\n<pre><code class=\"language-typescript\">class Person {\n  name: string = &#039;&#039;\n  age: number = 0\n  constructor (n: string) {\n    this.name = n;\n  }\n  fullName(): string {\n    return this.name;\n  }\n}<\/code><\/pre>\n<h3>\u5b57\u6bb5<\/h3>\n<p>\u5728\u7c7b\u4e2d\u58f0\u660e\u7684\u67d0\u79cd\u7c7b\u578b\u7684\u53d8\u91cf\u3002<\/p>\n<h4>\u5b9e\u4f8b\u5b57\u6bb5<\/h4>\n<p>\u5b58\u4e8e\u5b9e\u4f8b\uff0c\u4f7f\u7528\u5b9e\u4f8b\u540d\u8bbf\u95ee\u3002<\/p>\n<h4>\u9759\u6001\u5b57\u6bb5<\/h4>\n<p>\u4f7f\u7528\u5173\u952e\u5b57 <code>static<\/code> \u5c06\u5b57\u6bb5\u58f0\u660e\u4e3a\u9759\u6001\u3002<\/p>\n<p>\u7c7b\u7684\u6240\u6709\u5b9e\u4f8b\u5171\u4eab\u4e00\u4e2a\u9759\u6001\u5b57\u6bb5\u3002<\/p>\n<p>\u4f7f\u7528\u7c7b\u540d\u8bbf\u95ee\u9759\u6001\u5b57\u6bb5\u3002<\/p>\n<pre><code class=\"language-typescript\">class Person {\n  static numberOfPersons = 0\n  constructor() {\n     \/\/ ...\n     Person.numberOfPersons++;\n     \/\/ ...\n  }\n}\n\nPerson.numberOfPersons;<\/code><\/pre>\n<h4>\u5b57\u6bb5\u521d\u59cb\u5316<\/h4>\n<p>\u6240\u6709\u5b57\u6bb5\u5728\u58f0\u660e\u65f6\u6216\u8005\u6784\u9020\u51fd\u6570\u4e2d\u663e\u5f0f\u521d\u59cb\u5316\u3002<\/p>\n<pre><code class=\"language-typescript\">class Person {\n  name: string \/\/ \u6ca1\u6709\u521d\u59cb\u5316, \u53ef\u80fd\u4e3a undefined\n\n  setName(n:string): void {\n    this.name = n;\n  }\n\n  getName(): string {\n    \/\/ \u5f00\u53d1\u8005\u4f7f\u7528&quot;string&quot;\u4f5c\u4e3a\u8fd4\u56de\u7c7b\u578b\uff0c\u8fd9\u9690\u85cf\u4e86name\u53ef\u80fd\u4e3a&quot;undefined&quot;\u7684\u4e8b\u5b9e\u3002\n    \/\/ \u66f4\u5408\u9002\u7684\u505a\u6cd5\u662f\u5c06\u8fd4\u56de\u7c7b\u578b\u6807\u6ce8\u4e3a&quot;string | undefined&quot;\uff0c\u4ee5\u544a\u8bc9\u5f00\u53d1\u8005\u8fd9\u4e2aAPI\u6240\u6709\u53ef\u80fd\u7684\u8fd4\u56de\u503c\u3002\n    return this.name;\n  }\n}\n\nlet jack = new Person();\n\/\/ \u5047\u8bbe\u4ee3\u7801\u4e2d\u6ca1\u6709\u5bf9name\u8d4b\u503c\uff0c\u4f8b\u5982\u8c03\u7528&quot;jack.setName(&#039;Jack&#039;)&quot;\njack.getName().length; \/\/ \u8fd0\u884c\u65f6\u5f02\u5e38\uff1aname is undefined<\/code><\/pre>\n<h4>getter \u548c setter<\/h4>\n<pre><code class=\"language-typescript\">class Person {\n  name: string = &#039;&#039;\n  private _age: number = 0\n  get age(): number { return this._age; }\n  set age(x: number) {\n    if (x &lt; 0) {\n      throw Error(&#039;Invalid age argument&#039;);\n    }\n    this._age = x;\n  }\n}\n\nlet p = new Person();\np.age; \/\/ \u8f93\u51fa0\np.age = -42; \/\/ \u8bbe\u7f6e\u65e0\u6548age\u503c\u4f1a\u629b\u51fa\u9519\u8bef<\/code><\/pre>\n<h3>\u65b9\u6cd5<\/h3>\n<h4>\u5b9e\u4f8b\u65b9\u6cd5<\/h4>\n<p>\u5b58\u4e8e\u5b9e\u4f8b\uff0c\u4f7f\u7528\u5b9e\u4f8b\u540d\u8bbf\u95ee\u3002<\/p>\n<h4>\u9759\u6001\u65b9\u6cd5<\/h4>\n<p>\u4f7f\u7528\u5173\u952e\u5b57 <code>static<\/code> \u5c06\u65b9\u6cd5\u58f0\u660e\u4e3a\u9759\u6001\u3002<\/p>\n<p>\u901a\u8fc7\u7c7b\u540d\u8c03\u7528\u9759\u6001\u65b9\u6cd5\u3002<\/p>\n<pre><code class=\"language-typescript\">class Cl {\n  static staticMethod(): string {\n    return &#039;this is a static method.&#039;;\n  }\n}\nconsole.log(Cl.staticMethod());<\/code><\/pre>\n<h3>\u7ee7\u627f<\/h3>\n<p>\u4e00\u4e2a\u7c7b\u53ef\u4ee5\u7ee7\u627f\u53e6\u4e00\u4e2a\u7c7b\uff08\u79f0\u4e3a\u57fa\u7c7b\uff09\uff0c\u5e76\u4f7f\u7528\u5b9e\u73b0\u591a\u4e2a\u63a5\u53e3\uff1a<\/p>\n<pre><code class=\"language-typescript\">class [extends BaseClassName] [implements listOfInterfaces] {\n  \/\/ ...\n}<\/code><\/pre>\n<p>\u7ee7\u627f\u7c7b\u7ee7\u627f\u57fa\u7c7b\u7684\u5b57\u6bb5\u548c\u65b9\u6cd5\uff0c\u4f46\u4e0d\u7ee7\u627f\u6784\u9020\u51fd\u6570\u3002<\/p>\n<p>\u7ee7\u627f\u7c7b\u53ef\u4ee5\u65b0\u589e\u5b9a\u4e49\u5b57\u6bb5\u548c\u65b9\u6cd5\uff0c\u4e5f\u53ef\u4ee5\u8986\u76d6\u5176\u57fa\u7c7b\u5b9a\u4e49\u7684\u65b9\u6cd5\u3002<\/p>\n<pre><code class=\"language-typescript\">class Person {\n  name: string = &#039;&#039;\n  private _age = 0\n  get age(): number {\n    return this._age;\n  }\n}\nclass Employee extends Person {\n  salary: number = 0\n  calculateTaxes(): number {\n    return this.salary * 0.42;\n  }\n}<\/code><\/pre>\n<p>\u5b9e\u73b0\u63a5\u53e3\u7684\u7c7b\u5fc5\u987b\u5b9e\u73b0\u5217\u51fa\u7684\u63a5\u53e3\u4e2d\u5b9a\u4e49\u7684\u6240\u6709\u65b9\u6cd5\u3002<\/p>\n<h4>\u7236\u7c7b\u8bbf\u95ee<\/h4>\n<p>\u5173\u952e\u5b57 <code>super<\/code> \u53ef\u7528\u4e8e\u8bbf\u95ee\u7236\u7c7b\u7684\u5b9e\u4f8b\u5b57\u6bb5\u3001\u5b9e\u4f8b\u65b9\u6cd5\u548c\u6784\u9020\u51fd\u6570<\/p>\n<pre><code class=\"language-typescript\">class RectangleSize {\n  protected height: number = 0\n  protected width: number = 0\n\n  constructor (h: number, w: number) {\n    this.height = h;\n    this.width = w;\n  }\n\n  draw() {\n    \/* \u7ed8\u5236\u8fb9\u754c *\/\n  }\n}\nclass FilledRectangle extends RectangleSize {\n  color = &#039;&#039;\n  constructor (h: number, w: number, c: string) {\n    super(h, w); \/\/ \u7236\u7c7b\u6784\u9020\u51fd\u6570\u7684\u8c03\u7528\n    this.color = c;\n  }\n\n  draw() {\n    super.draw(); \/\/ \u7236\u7c7b\u65b9\u6cd5\u7684\u8c03\u7528\n    \/\/ super.height -\u53ef\u5728\u6b64\u5904\u4f7f\u7528\n    \/* \u586b\u5145\u77e9\u5f62 *\/\n  }\n}<\/code><\/pre>\n<h4>\u65b9\u6cd5\u91cd\u5199<\/h4>\n<pre><code class=\"language-typescript\">class RectangleSize {\n  \/\/ ...\n  area(): number {\n    \/\/ \u5b9e\u73b0\n    return 0;\n  }\n}\nclass Square extends RectangleSize {\n  private side: number = 0\n  area(): number {\n    return this.side * this.side;\n  }\n}<\/code><\/pre>\n<h3>\u6784\u9020\u51fd\u6570<\/h3>\n<pre><code class=\"language-typescript\">class C {\n  constructor ([parameters]) {\n  \/\/ ...\n  }\n}<\/code><\/pre>\n<p>\u5982\u679c\u672a\u5b9a\u4e49\u6784\u9020\u51fd\u6570\uff0c\u5219\u4f1a\u81ea\u52a8\u521b\u5efa\u5177\u6709\u7a7a\u53c2\u6570\u5217\u8868\u7684\u9ed8\u8ba4\u6784\u9020\u51fd\u6570\u3002<\/p>\n<h3>\u53ef\u89c1\u6027\u4fee\u9970\u7b26<\/h3>\n<h4>Public\uff08\u516c\u6709\uff09<\/h4>\n<p>public \u4fee\u9970\u7684\u7c7b\u6210\u5458\uff08\u5b57\u6bb5\u3001\u65b9\u6cd5\u3001\u6784\u9020\u51fd\u6570\uff09\u5728\u7a0b\u5e8f\u7684\u4efb\u4f55\u53ef\u8bbf\u95ee\u8be5\u7c7b\u7684\u5730\u65b9\u90fd\u662f\u53ef\u89c1\u7684\u3002<\/p>\n<h4>Private\uff08\u79c1\u6709\uff09<\/h4>\n<p>private \u4fee\u9970\u7684\u6210\u5458\u4e0d\u80fd\u5728\u58f0\u660e\u8be5\u6210\u5458\u7684\u7c7b\u4e4b\u5916\u8bbf\u95ee\u3002<\/p>\n<h4>Protected\uff08\u53d7\u4fdd\u62a4\uff09<\/h4>\n<p>protected \u4fee\u9970\u7b26\u7684\u4f5c\u7528\u4e0e private \u4fee\u9970\u7b26\u975e\u5e38\u76f8\u4f3c\uff0c\u4e0d\u540c\u70b9\u662f protected\u4fee\u9970\u7684\u6210\u5458\u5141\u8bb8\u5728\u6d3e\u751f\u7c7b\uff08\u5b50\u7c7b\uff09\u4e2d\u8bbf\u95ee\u3002<\/p>\n<pre><code class=\"language-typescript\">class Base {\n  protected x: string = &#039;&#039;\n  private y: string = &#039;&#039;\n}\nclass Derived extends Base {\n  foo() {\n    this.x = &#039;a&#039;; \/\/ \u8bbf\u95ee\u53d7\u4fdd\u62a4\u6210\u5458\n    this.y = &#039;b&#039;; \/\/ \u7f16\u8bd1\u65f6\u9519\u8bef\uff0c&#039;y&#039;\u4e0d\u53ef\u89c1\uff0c\u56e0\u4e3a\u5b83\u662f\u79c1\u6709\u7684\n  }\n}<\/code><\/pre>\n<h3>\u5bf9\u8c61\u5b57\u9762\u91cf<\/h3>\n<p>\u7528\u4e8e\u66f4\u65b9\u4fbf\u5730\u521b\u5efa\u7c7b\u5b9e\u4f8b\u5e76\u63d0\u4f9b\u4e00\u4e9b\u521d\u59cb\u503c\u3002<\/p>\n<pre><code class=\"language-typescript\">\/\/ \u5b9a\u4e49\nclass C {\n  n: number = 0\n  s: string = &#039;&#039;\n}\n\/\/ \u521b\u5efa\u5b9e\u4f8b\nlet c: C = {n: 42, s: &#039;foo&#039;};<\/code><\/pre>\n<h4>Record\u7c7b\u578b\u7684\u5bf9\u8c61\u5b57\u9762\u91cf<\/h4>\n<p>\u7528\u4e8e\u5c06\u7c7b\u578b\uff08\u952e\u7c7b\u578b\uff09\u7684\u5c5e\u6027\u6620\u5c04\u5230\u53e6\u4e00\u4e2a\u7c7b\u578b\uff08\u503c\u7c7b\u578b\uff09\u3002<\/p>\n<pre><code class=\"language-typescript\">let map: Record&lt;string, number&gt; = {\n  &#039;John&#039;: 25,\n  &#039;Mary&#039;: 21,\n}\n\nmap[&#039;John&#039;]; \/\/ 25<\/code><\/pre>\n<pre><code class=\"language-typescript\">interface PersonInfo {\n  age: number\n  salary: number\n}\n\nlet map: Record&lt;string, PersonInfo&gt; = {\n  &#039;John&#039;: { age: 25, salary: 10},\n  &#039;Mary&#039;: { age: 21, salary: 20}\n}<\/code><\/pre>\n<h2>\u63a5\u53e3<\/h2>\n<pre><code class=\"language-typescript\">\/\/ \u63a5\u53e3\uff1a\ninterface AreaSize {\n  area: number \/\/ \u5c5e\u6027\n  calculateAreaSize(): number \/\/ \u65b9\u6cd5\u7684\u58f0\u660e\n  someMethod(): void;     \/\/ \u65b9\u6cd5\u7684\u58f0\u660e\n}\n\n\/\/ \u63a5\u53e3\u5b9e\u73b0\uff1a\nclass RectangleSize implements AreaSize {\n  area: number = 0;\n  private width: number = 0\n  private height: number = 0\n  someMethod(): void {\n    console.log(&#039;someMethod called&#039;);\n  }\n  calculateAreaSize(): number {\n    this.someMethod(); \/\/ \u8c03\u7528\u53e6\u4e00\u4e2a\u65b9\u6cd5\u5e76\u8fd4\u56de\u7ed3\u679c\n    this.area = this.width * this.height\n    return this.area;\n  }\n}<\/code><\/pre>\n<h3>\u63a5\u53e3\u7ee7\u627f<\/h3>\n<pre><code class=\"language-typescript\">interface Style {\n  color: string\n}\n\ninterface ExtendedStyle extends Style {\n  width: number\n}<\/code><\/pre>\n<h2>\u6cdb\u578b\u7c7b\u578b\u548c\u51fd\u6570<\/h2>\n<p>\u4f7f\u5176\u652f\u6301\u591a\u79cd\u6570\u636e\u7c7b\u578b\u3002<\/p>\n<h3>\u6cdb\u578b\u7c7b\u548c\u63a5\u53e3<\/h3>\n<pre><code class=\"language-typescript\">class CustomStack&lt;Element&gt; {\n  public push(e: Element):void {\n    console.log(`${e}`)\n  }\n}\nlet s = new CustomStack&lt;string&gt;();\ns.push(&#039;hello&#039;);<\/code><\/pre>\n<pre><code class=\"language-typescript\">interface Pair&lt;T, U&gt; {\n  first: T;\n  second: U;\n}\n\nlet pair: Pair&lt;number, string&gt; = { first: 1, second: &quot;two&quot; };<\/code><\/pre>\n<p><code>&lt;&gt;<\/code>\u53ef\u4ee5\u5bf9\u7c7b\u578b\u8fdb\u884c\u7ea6\u675f\u3002<\/p>\n<h3>\u6cdb\u578b\u51fd\u6570<\/h3>\n<pre><code class=\"language-typescript\">function last&lt;T&gt;(x: T[]): T {\n  return x[x.length - 1];\n}\nlast([1, 2, 3]);\nlast&lt;string&gt;([&#039;aa&#039;, &#039;bb&#039;]);<\/code><\/pre>\n<h2>\u7a7a\u5b89\u5168<\/h2>\n<p>\u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0cArkTS\u4e2d\u7684\u6240\u6709\u7c7b\u578b\u90fd\u662f\u4e0d\u53ef\u4e3a\u7a7a\u7684\u3002<\/p>\n<pre><code class=\"language-typescript\">let x: number = null;    \/\/ \u7f16\u8bd1\u65f6\u9519\u8bef\nlet y: string = null;    \/\/ \u7f16\u8bd1\u65f6\u9519\u8bef\nlet z: number[] = null;  \/\/ \u7f16\u8bd1\u65f6\u9519\u8bef\n\nlet x: number | null = null;\nx = 1;    \/\/ ok\nx = null; \/\/ ok\nif (x != null) { \/* do something *\/ }<\/code><\/pre>\n<h3>\u975e\u7a7a\u65ad\u8a00\u8fd0\u7b97\u7b26<\/h3>\n<p>\u4f7f\u7c7b\u578b\u4e0d\u4e3a\u7a7a\uff0c\u7528\u6cd5\u4e3a\u540e\u7f00\u611f\u53f9\u53f7 <code>!<\/code><\/p>\n<pre><code class=\"language-typescript\">let b = null;\nlet x: number;\nx = b! + 1;\n\nclass C {\n  value: number | null = 1;\n}\n\nlet c = new C();\nlet y: number;\ny = c.value + 1;  \/\/ \u7f16\u8bd1\u65f6\u9519\u8bef\uff1a\u65e0\u6cd5\u5bf9\u53ef\u7a7a\u503c\u4f5c\u505a\u52a0\u6cd5\ny = c.value! + 1; \/\/ ok\uff0c\u503c\u4e3a2<\/code><\/pre>\n<h3>\u7a7a\u503c\u5408\u5e76\u8fd0\u7b97\u7b26<\/h3>\n<p><code>??<\/code>\uff0c\u68c0\u67e5\u5de6\u4fa7\u8868\u8fbe\u5f0f\u7684\u6c42\u503c\u662f\u5426\u7b49\u4e8e<code>null<\/code>\u6216\u8005<code>undefined<\/code>\u3002<\/p>\n<p>\u5982\u679c\u662f\uff0c\u5219\u8868\u8fbe\u5f0f\u7684\u7ed3\u679c\u4e3a\u53f3\u4fa7\u8868\u8fbe\u5f0f\uff1b\u5426\u5219\uff0c\u7ed3\u679c\u4e3a\u5de6\u4fa7\u8868\u8fbe\u5f0f\u3002<\/p>\n<pre><code class=\"language-typescript\">class Person {\n  \/\/ ...\n  nick: string | null = null\n  getNick(): string {\n    return this.nick ?? &#039;&#039;; \/\/ \u82e5\u6635\u79f0\u4e3a\u7a7a\uff0c\u5219\u8fd4\u56de\u7a7a\u5b57\u7b26\u4e32\n  }\n}<\/code><\/pre>\n<h3>\u53ef\u9009\u94fe<\/h3>\n<p><code>?.<\/code> \uff0c\u7528\u4e8e\u8bbf\u95ee\u5bf9\u8c61\u5c5e\u6027\u3001\u8c03\u7528\u65b9\u6cd5\u4ee5\u53ca\u8bbf\u95ee\u6570\u7ec4\u5143\u7d20\u7b49\u573a\u666f\uff0c<\/p>\n<p>\u5982\u679c\u8be5\u5c5e\u6027\u662fundefined\u6216\u8005null\uff0c\u53ef\u9009\u94fe\u8fd0\u7b97\u7b26\u4f1a\u8fd4\u56deundefined<\/p>\n<pre><code class=\"language-typescript\">let user: { address?: { street?: string } } = {};\n\nconsole.log(user.address?.street); \/\/ \u8f93\u51fa: undefined\n\nlet user = {\n  name: &quot;Alice&quot;,\n  greet: () =&gt; &quot;Hello&quot;\n};\n\nconsole.log(user.greet?.()); \/\/ \u8f93\u51fa: &quot;Hello&quot;\n\nlet anotherUser = { name: &quot;Bob&quot; };\nconsole.log(anotherUser.greet?.()); \/\/ \u8f93\u51fa: undefined<\/code><\/pre>\n<h2>\u6a21\u5757<\/h2>\n<p>\u7a0b\u5e8f\u53ef\u5212\u5206\u4e3a\u591a\u7ec4\u7f16\u8bd1\u5355\u5143\u6216\u6a21\u5757\u3002<\/p>\n<h3>\u5bfc\u51fa<\/h3>\n<p>\u4f7f\u7528\u5173\u952e\u5b57export\u5bfc\u51fa\u9876\u5c42\u7684\u58f0\u660e\u3002<\/p>\n<pre><code class=\"language-typescript\">export class Point {\n  x: number = 0\n  y: number = 0\n  constructor(x: number, y: number) {\n    this.x = x;\n    this.y = y;\n  }\n}\nexport let Origin = new Point(0, 0);\nexport function Distance(p1: Point, p2: Point): number {\n  return Math.sqrt((p2.x - p1.x) * (p2.x - p1.x) + (p2.y - p1.y) * (p2.y - p1.y));\n}<\/code><\/pre>\n<h3>\u5bfc\u5165<\/h3>\n<h4>\u9759\u6001\u5bfc\u5165<\/h4>\n<pre><code class=\"language-typescript\">import * as Utils from &#039;.\/utils&#039;\nUtils.X \/\/ \u8868\u793a\u6765\u81eaUtils\u7684X\nUtils.Y \/\/ \u8868\u793a\u6765\u81eaUtils\u7684Y\n\nimport { X, Y } from &#039;.\/utils&#039;\nX \/\/ \u8868\u793a\u6765\u81eautils\u7684X\nY \/\/ \u8868\u793a\u6765\u81eautils\u7684Y\n\nimport { X as Z, Y } from &#039;.\/utils&#039;\nZ \/\/ \u8868\u793a\u6765\u81eaUtils\u7684X\nY \/\/ \u8868\u793a\u6765\u81eaUtils\u7684Y\nX \/\/ \u7f16\u8bd1\u65f6\u9519\u8bef\uff1a&#039;X&#039;\u4e0d\u53ef\u89c1<\/code><\/pre>\n<h4>\u52a8\u6001\u5bfc\u5165<\/h4>\n<p>\u7528\u4e8e\u5b9e\u73b0\u6839\u636e\u6761\u4ef6\u5bfc\u5165\u6a21\u5757\u6216\u8005\u6309\u9700\u5bfc\u5165\u6a21\u5757\u3002<\/p>\n<pre><code class=\"language-typescript\">\/\/ say.ts\nexport function hi() {\n  console.log(&#039;Hello&#039;);\n}\nexport function bye() {\n  console.log(&#039;Bye&#039;);\n}<\/code><\/pre>\n<pre><code class=\"language-typescript\">\/\/ index.ets\nasync function test() {\n  let ns = await import(&#039;.\/say&#039;);\n  let hi = ns.hi;\n  let bye = ns.bye;\n  hi();\n  bye();\n}<\/code><\/pre>\n<h4>\u5bfc\u5165HarmonyOS SDK\u7684\u5f00\u653e\u80fd\u529b<\/h4>\n<p>\u5bfc\u5165\u63a5\u53e3\u6a21\u5757\uff1a<\/p>\n<pre><code class=\"language-typescript\">import UIAbility from &#039;@ohos.app.ability.UIAbility&#039;;<\/code><\/pre>\n<p>\u4eceHarmonyOS NEXT Developer Preview 1\u7248\u672c\u5f00\u59cb\u5f15\u5165Kit\u6982\u5ff5\u3002SDK\u5bf9\u540c\u4e00\u4e2aKit\u4e0b\u7684\u63a5\u53e3\u6a21\u5757\u8fdb\u884c\u4e86\u5c01\u88c5\uff0c\u5f00\u53d1\u8005\u5728\u793a\u4f8b\u4ee3\u7801\u4e2d\u53ef\u901a\u8fc7\u5bfc\u5165Kit\u7684\u65b9\u5f0f\u6765\u4f7f\u7528Kit\u6240\u5305\u542b\u7684\u63a5\u53e3\u80fd\u529b\u3002<\/p>\n<p>\u5176\u4e2d\uff0cKit\u5c01\u88c5\u7684\u63a5\u53e3\u6a21\u5757\u53ef\u67e5\u770bSDK\u76ee\u5f55\u4e0bKit\u5b50\u76ee\u5f55\u4e2d\u5404Kit\u7684\u5b9a\u4e49\u3002<\/p>\n<p>\u901a\u8fc7\u5bfc\u5165Kit\u65b9\u5f0f\u4f7f\u7528\u5f00\u653e\u80fd\u529b\u6709\u4e09\u79cd\u65b9\u5f0f\uff1a<\/p>\n<ul>\n<li>\n<p>\u65b9\u5f0f\u4e00\uff1a\u5bfc\u5165Kit\u4e0b\u5355\u4e2a\u6a21\u5757\u7684\u63a5\u53e3\u80fd\u529b\u3002\u4f8b\u5982\uff1a<\/p>\n<pre><code class=\"language-typescript\">import { UIAbility } from '@kit.AbilityKit';\n\/\/ AbilityKit - \u7a0b\u5e8f\u6846\u67b6\u670d\u52a1\n\/\/ UIAbility - \u5305\u542bUI\u754c\u9762\u7684\u5e94\u7528\u7ec4\u4ef6<\/code><\/pre>\n<\/li>\n<li>\n<p>\u65b9\u5f0f\u4e8c\uff1a\u5bfc\u5165Kit\u4e0b\u591a\u4e2a\u6a21\u5757\u7684\u63a5\u53e3\u80fd\u529b\u3002\u4f8b\u5982\uff1a<\/p>\n<pre><code class=\"language-typescript\">import { UIAbility, Ability, Context } from '@kit.AbilityKit';\n\/\/ Ability - UIAbility\u548cExtensionAbility\u7684\u57fa\u7c7b\uff0c\n\/\/ \u63d0\u4f9b\u7cfb\u7edf\u914d\u7f6e\u66f4\u65b0\u56de\u8c03\u548c\u7cfb\u7edf\u5185\u5b58\u8c03\u6574\u56de\u8c03<\/code><\/pre>\n<\/li>\n<li>\n<p>\u65b9\u5f0f\u4e09\uff1a\u5bfc\u5165Kit\u5305\u542b\u7684\u6240\u6709\u6a21\u5757\u7684\u63a5\u53e3\u80fd\u529b\u3002\u4f8b\u5982\uff1a<\/p>\n<pre><code class=\"language-typescript\">import * as module from '@kit.AbilityKit';<\/code><\/pre>\n<p>\u5176\u4e2d\uff0c\u201cmodule\u201d\u4e3a\u522b\u540d\uff0c\u53ef\u81ea\u5b9a\u4e49\uff0c\u7136\u540e\u901a\u8fc7\u8be5\u540d\u79f0\u8c03\u7528\u6a21\u5757\u7684\u63a5\u53e3\u3002<\/p>\n<\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>\u53c2\u8003\u6587\u6863\uff1a\u521d\u8bc6ArkTS\u8bed\u8a00-\u5b66\u4e60ArkTS\u8bed\u8a00-\u57fa\u7840\u5165\u95e8 | \u534e\u4e3a\u5f00\u53d1\u8005\u8054\u76df (huawei.com) \u73af\u5883 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_uag_custom_page_level_css":"","site-sidebar-layout":"default","site-content-layout":"","ast-site-content-layout":"default","site-content-style":"default","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","theme-transparent-header-meta":"default","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"set","ast-page-background-enabled":"default","ast-page-background-meta":{"desktop":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"ast-content-background-meta":{"desktop":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"footnotes":""},"categories":[12,9],"tags":[],"class_list":["post-4839","post","type-post","status-publish","format-standard","hentry","category-harmonyos","category-9"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v23.4 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>ArkTS - Drama&#039;s Blog<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.ddddrama.top\/index.php\/2024\/06\/28\/arkts\/\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"ArkTS - Drama&#039;s Blog\" \/>\n<meta property=\"og:description\" content=\"\u53c2\u8003\u6587\u6863\uff1a\u521d\u8bc6ArkTS\u8bed\u8a00-\u5b66\u4e60ArkTS\u8bed\u8a00-\u57fa\u7840\u5165\u95e8 | \u534e\u4e3a\u5f00\u53d1\u8005\u8054\u76df (huawei.com) \u73af\u5883 [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.ddddrama.top\/index.php\/2024\/06\/28\/arkts\/\" \/>\n<meta property=\"og:site_name\" content=\"Drama&#039;s Blog\" \/>\n<meta property=\"article:published_time\" content=\"2024-06-28T11:59:41+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2024-07-25T06:31:59+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.ddddrama.top\/wp-content\/uploads\/2024\/06\/image-1719656423596.20240625162806.65988528664452518825772083342308500012310000002800371F093F8FC0DAF21E2460C9723548A6A2E4BD5BF52DCB36CDD093ECD9C827BB-300x279.png\" \/>\n<meta name=\"author\" content=\"Drama\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u4f5c\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"Drama\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4\" \/>\n\t<meta name=\"twitter:data2\" content=\"8 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/www.ddddrama.top\/index.php\/2024\/06\/28\/arkts\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.ddddrama.top\/index.php\/2024\/06\/28\/arkts\/\"},\"author\":{\"name\":\"Drama\",\"@id\":\"https:\/\/www.ddddrama.top\/#\/schema\/person\/ad8e98934ba5081a49853d6b020f6fb0\"},\"headline\":\"ArkTS\",\"datePublished\":\"2024-06-28T11:59:41+00:00\",\"dateModified\":\"2024-07-25T06:31:59+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.ddddrama.top\/index.php\/2024\/06\/28\/arkts\/\"},\"wordCount\":151,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/www.ddddrama.top\/#\/schema\/person\/ad8e98934ba5081a49853d6b020f6fb0\"},\"image\":{\"@id\":\"https:\/\/www.ddddrama.top\/index.php\/2024\/06\/28\/arkts\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.ddddrama.top\/wp-content\/uploads\/2024\/06\/image-1719656423596.20240625162806.65988528664452518825772083342308500012310000002800371F093F8FC0DAF21E2460C9723548A6A2E4BD5BF52DCB36CDD093ECD9C827BB-300x279.png\",\"articleSection\":[\"HarmonyOS\",\"\u5b66\u4e60\"],\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/www.ddddrama.top\/index.php\/2024\/06\/28\/arkts\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.ddddrama.top\/index.php\/2024\/06\/28\/arkts\/\",\"url\":\"https:\/\/www.ddddrama.top\/index.php\/2024\/06\/28\/arkts\/\",\"name\":\"ArkTS - Drama&#039;s Blog\",\"isPartOf\":{\"@id\":\"https:\/\/www.ddddrama.top\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/www.ddddrama.top\/index.php\/2024\/06\/28\/arkts\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/www.ddddrama.top\/index.php\/2024\/06\/28\/arkts\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.ddddrama.top\/wp-content\/uploads\/2024\/06\/image-1719656423596.20240625162806.65988528664452518825772083342308500012310000002800371F093F8FC0DAF21E2460C9723548A6A2E4BD5BF52DCB36CDD093ECD9C827BB-300x279.png\",\"datePublished\":\"2024-06-28T11:59:41+00:00\",\"dateModified\":\"2024-07-25T06:31:59+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/www.ddddrama.top\/index.php\/2024\/06\/28\/arkts\/#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.ddddrama.top\/index.php\/2024\/06\/28\/arkts\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.ddddrama.top\/index.php\/2024\/06\/28\/arkts\/#primaryimage\",\"url\":\"https:\/\/www.ddddrama.top\/wp-content\/uploads\/2024\/06\/image-1719656423596.20240625162806.65988528664452518825772083342308500012310000002800371F093F8FC0DAF21E2460C9723548A6A2E4BD5BF52DCB36CDD093ECD9C827BB.png\",\"contentUrl\":\"https:\/\/www.ddddrama.top\/wp-content\/uploads\/2024\/06\/image-1719656423596.20240625162806.65988528664452518825772083342308500012310000002800371F093F8FC0DAF21E2460C9723548A6A2E4BD5BF52DCB36CDD093ECD9C827BB.png\",\"width\":518,\"height\":481},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.ddddrama.top\/index.php\/2024\/06\/28\/arkts\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.ddddrama.top\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"ArkTS\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.ddddrama.top\/#website\",\"url\":\"https:\/\/www.ddddrama.top\/\",\"name\":\"Drama\u2018s Blog\",\"description\":\"Make it Possible\",\"publisher\":{\"@id\":\"https:\/\/www.ddddrama.top\/#\/schema\/person\/ad8e98934ba5081a49853d6b020f6fb0\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.ddddrama.top\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"zh-Hans\"},{\"@type\":[\"Person\",\"Organization\"],\"@id\":\"https:\/\/www.ddddrama.top\/#\/schema\/person\/ad8e98934ba5081a49853d6b020f6fb0\",\"name\":\"Drama\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.ddddrama.top\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/www.ddddrama.top\/wp-content\/uploads\/2023\/12\/Drama-scaled.webp\",\"contentUrl\":\"https:\/\/www.ddddrama.top\/wp-content\/uploads\/2023\/12\/Drama-scaled.webp\",\"width\":2560,\"height\":443,\"caption\":\"Drama\"},\"logo\":{\"@id\":\"https:\/\/www.ddddrama.top\/#\/schema\/person\/image\/\"},\"sameAs\":[\"https:\/\/www.ddddrama.top\/\"],\"url\":\"https:\/\/www.ddddrama.top\/index.php\/author\/drama\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"ArkTS - Drama&#039;s Blog","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.ddddrama.top\/index.php\/2024\/06\/28\/arkts\/","og_locale":"zh_CN","og_type":"article","og_title":"ArkTS - Drama&#039;s Blog","og_description":"\u53c2\u8003\u6587\u6863\uff1a\u521d\u8bc6ArkTS\u8bed\u8a00-\u5b66\u4e60ArkTS\u8bed\u8a00-\u57fa\u7840\u5165\u95e8 | \u534e\u4e3a\u5f00\u53d1\u8005\u8054\u76df (huawei.com) \u73af\u5883 [&hellip;]","og_url":"https:\/\/www.ddddrama.top\/index.php\/2024\/06\/28\/arkts\/","og_site_name":"Drama&#039;s Blog","article_published_time":"2024-06-28T11:59:41+00:00","article_modified_time":"2024-07-25T06:31:59+00:00","og_image":[{"url":"https:\/\/www.ddddrama.top\/wp-content\/uploads\/2024\/06\/image-1719656423596.20240625162806.65988528664452518825772083342308500012310000002800371F093F8FC0DAF21E2460C9723548A6A2E4BD5BF52DCB36CDD093ECD9C827BB-300x279.png"}],"author":"Drama","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"Drama","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"8 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.ddddrama.top\/index.php\/2024\/06\/28\/arkts\/#article","isPartOf":{"@id":"https:\/\/www.ddddrama.top\/index.php\/2024\/06\/28\/arkts\/"},"author":{"name":"Drama","@id":"https:\/\/www.ddddrama.top\/#\/schema\/person\/ad8e98934ba5081a49853d6b020f6fb0"},"headline":"ArkTS","datePublished":"2024-06-28T11:59:41+00:00","dateModified":"2024-07-25T06:31:59+00:00","mainEntityOfPage":{"@id":"https:\/\/www.ddddrama.top\/index.php\/2024\/06\/28\/arkts\/"},"wordCount":151,"commentCount":0,"publisher":{"@id":"https:\/\/www.ddddrama.top\/#\/schema\/person\/ad8e98934ba5081a49853d6b020f6fb0"},"image":{"@id":"https:\/\/www.ddddrama.top\/index.php\/2024\/06\/28\/arkts\/#primaryimage"},"thumbnailUrl":"https:\/\/www.ddddrama.top\/wp-content\/uploads\/2024\/06\/image-1719656423596.20240625162806.65988528664452518825772083342308500012310000002800371F093F8FC0DAF21E2460C9723548A6A2E4BD5BF52DCB36CDD093ECD9C827BB-300x279.png","articleSection":["HarmonyOS","\u5b66\u4e60"],"inLanguage":"zh-Hans","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.ddddrama.top\/index.php\/2024\/06\/28\/arkts\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.ddddrama.top\/index.php\/2024\/06\/28\/arkts\/","url":"https:\/\/www.ddddrama.top\/index.php\/2024\/06\/28\/arkts\/","name":"ArkTS - Drama&#039;s Blog","isPartOf":{"@id":"https:\/\/www.ddddrama.top\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.ddddrama.top\/index.php\/2024\/06\/28\/arkts\/#primaryimage"},"image":{"@id":"https:\/\/www.ddddrama.top\/index.php\/2024\/06\/28\/arkts\/#primaryimage"},"thumbnailUrl":"https:\/\/www.ddddrama.top\/wp-content\/uploads\/2024\/06\/image-1719656423596.20240625162806.65988528664452518825772083342308500012310000002800371F093F8FC0DAF21E2460C9723548A6A2E4BD5BF52DCB36CDD093ECD9C827BB-300x279.png","datePublished":"2024-06-28T11:59:41+00:00","dateModified":"2024-07-25T06:31:59+00:00","breadcrumb":{"@id":"https:\/\/www.ddddrama.top\/index.php\/2024\/06\/28\/arkts\/#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.ddddrama.top\/index.php\/2024\/06\/28\/arkts\/"]}]},{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.ddddrama.top\/index.php\/2024\/06\/28\/arkts\/#primaryimage","url":"https:\/\/www.ddddrama.top\/wp-content\/uploads\/2024\/06\/image-1719656423596.20240625162806.65988528664452518825772083342308500012310000002800371F093F8FC0DAF21E2460C9723548A6A2E4BD5BF52DCB36CDD093ECD9C827BB.png","contentUrl":"https:\/\/www.ddddrama.top\/wp-content\/uploads\/2024\/06\/image-1719656423596.20240625162806.65988528664452518825772083342308500012310000002800371F093F8FC0DAF21E2460C9723548A6A2E4BD5BF52DCB36CDD093ECD9C827BB.png","width":518,"height":481},{"@type":"BreadcrumbList","@id":"https:\/\/www.ddddrama.top\/index.php\/2024\/06\/28\/arkts\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.ddddrama.top\/"},{"@type":"ListItem","position":2,"name":"ArkTS"}]},{"@type":"WebSite","@id":"https:\/\/www.ddddrama.top\/#website","url":"https:\/\/www.ddddrama.top\/","name":"Drama\u2018s Blog","description":"Make it Possible","publisher":{"@id":"https:\/\/www.ddddrama.top\/#\/schema\/person\/ad8e98934ba5081a49853d6b020f6fb0"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.ddddrama.top\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"zh-Hans"},{"@type":["Person","Organization"],"@id":"https:\/\/www.ddddrama.top\/#\/schema\/person\/ad8e98934ba5081a49853d6b020f6fb0","name":"Drama","image":{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.ddddrama.top\/#\/schema\/person\/image\/","url":"https:\/\/www.ddddrama.top\/wp-content\/uploads\/2023\/12\/Drama-scaled.webp","contentUrl":"https:\/\/www.ddddrama.top\/wp-content\/uploads\/2023\/12\/Drama-scaled.webp","width":2560,"height":443,"caption":"Drama"},"logo":{"@id":"https:\/\/www.ddddrama.top\/#\/schema\/person\/image\/"},"sameAs":["https:\/\/www.ddddrama.top\/"],"url":"https:\/\/www.ddddrama.top\/index.php\/author\/drama\/"}]}},"uagb_featured_image_src":{"full":false,"thumbnail":false,"medium":false,"medium_large":false,"large":false,"1536x1536":false,"2048x2048":false},"uagb_author_info":{"display_name":"Drama","author_link":"https:\/\/www.ddddrama.top\/index.php\/author\/drama\/"},"uagb_comment_info":0,"uagb_excerpt":"\u53c2\u8003\u6587\u6863\uff1a\u521d\u8bc6ArkTS\u8bed\u8a00-\u5b66\u4e60ArkTS\u8bed\u8a00-\u57fa\u7840\u5165\u95e8 | \u534e\u4e3a\u5f00\u53d1\u8005\u8054\u76df (huawei.com) \u73af\u5883&hellip;","_links":{"self":[{"href":"https:\/\/www.ddddrama.top\/index.php\/wp-json\/wp\/v2\/posts\/4839","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.ddddrama.top\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.ddddrama.top\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.ddddrama.top\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.ddddrama.top\/index.php\/wp-json\/wp\/v2\/comments?post=4839"}],"version-history":[{"count":17,"href":"https:\/\/www.ddddrama.top\/index.php\/wp-json\/wp\/v2\/posts\/4839\/revisions"}],"predecessor-version":[{"id":5032,"href":"https:\/\/www.ddddrama.top\/index.php\/wp-json\/wp\/v2\/posts\/4839\/revisions\/5032"}],"wp:attachment":[{"href":"https:\/\/www.ddddrama.top\/index.php\/wp-json\/wp\/v2\/media?parent=4839"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.ddddrama.top\/index.php\/wp-json\/wp\/v2\/categories?post=4839"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.ddddrama.top\/index.php\/wp-json\/wp\/v2\/tags?post=4839"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}