{"id":70813,"date":"2026-02-02T12:58:53","date_gmt":"2026-02-02T04:58:53","guid":{"rendered":"https:\/\/www.wsisp.com\/helps\/70813.html"},"modified":"2026-02-02T12:58:53","modified_gmt":"2026-02-02T04:58:53","slug":"typescript%e5%88%b0arkts%ef%bc%9a%e9%b8%bf%e8%92%99%e5%bc%80%e5%8f%91%e8%80%85%e7%9a%84%e5%bf%85%e7%9f%a5%e5%b7%ae%e5%bc%82","status":"publish","type":"post","link":"https:\/\/www.wsisp.com\/helps\/70813.html","title":{"rendered":"TypeScript\u5230ArkTS\uff1a\u9e3f\u8499\u5f00\u53d1\u8005\u7684\u5fc5\u77e5\u5dee\u5f02"},"content":{"rendered":"<p>\u4f5c\u4e3a\u524d\u7aef\u5f00\u53d1\u8005&#xff0c;\u6211\u4eec\u5df2\u7ecf\u4e60\u60ef\u4e86 TypeScript \u5e26\u6765\u7684\u7c7b\u578b\u5b89\u5168\u4e0e\u5f00\u53d1\u6548\u7387\u3002\u4f46\u5f53\u89c6\u7ebf\u8f6c\u5411\u9e3f\u8499\u751f\u6001&#xff08;HarmonyOS&#xff09;\u65f6&#xff0c;\u4e00\u4e2a\u719f\u6089\u53c8\u964c\u751f\u7684\u540d\u5b57\u51fa\u73b0\u4e86\u2014\u2014ArkTS\u3002\u5b83\u770b\u8d77\u6765\u50cf\u6781\u4e86\u6211\u4eec\u719f\u6089\u7684 TS&#xff0c;\u5374\u53c8\u6709\u4e00\u4e9b&#034;\u4e0d\u5408\u5e38\u7406&#034;\u7684\u4e25\u683c\u7ea6\u675f&#xff1a;\u4e0d\u80fd\u968f\u610f\u7ed9\u5bf9\u8c61\u52a0\u5c5e\u6027\u4e86&#xff0c;any \u7c7b\u578b\u88ab\u9650\u5236\u4e86&#xff0c;\u751a\u81f3\u8fde &#043; \u8fd0\u7b97\u7b26\u90fd\u4e0d\u80fd\u968f\u4fbf\u62fc\u63a5\u5b57\u7b26\u4e32\u4e86\u3002 \u8fd9\u5230\u5e95\u662f\u8bed\u8a00\u7684\u5012\u9000&#xff0c;\u8fd8\u662f\u4e3a\u4e86\u6781\u81f4\u6027\u80fd\u7684\u5fc5\u7136\u9009\u62e9&#xff1f;\u8fd9\u7bc7\u6587\u7ae0\u5c06\u5e26\u4f60\u7406\u89e3 ArkTS \u7684\u8bbe\u8ba1\u54f2\u5b66&#xff0c;\u5e76\u5e2e\u52a9\u6709 TypeScript \u80cc\u666f\u7684\u5f00\u53d1\u8005\u5feb\u901f\u5b8c\u6210\u8ba4\u77e5\u8fc1\u79fb\u3002<\/p>\n<h4>\u4e00\u3001ArkTS&#xff1a;\u7ad9\u5728 TypeScript \u80a9\u8180\u4e0a\u7684\u9e3f\u8499\u5b98\u914d<\/h4>\n<p>ArkTS \u662f HarmonyOS \u5e94\u7528\u5f00\u53d1\u7684\u9996\u9009\u8bed\u8a00&#xff0c;\u5b83\u57fa\u4e8e TypeScript \u751f\u6001\u6784\u5efa&#xff0c;\u4fdd\u7559\u4e86 TS \u7684\u8bed\u6cd5\u98ce\u683c\u548c\u7c7b\u578b\u7cfb\u7edf\u57fa\u7840&#xff0c;\u4f46\u901a\u8fc7\u7f16\u8bd1\u5668\u5c42\u9762\u7684\u5f3a\u5316&#xff08;ArkCompiler&#xff09;&#xff0c;\u5b9e\u73b0\u4e86\u66f4\u4e25\u683c\u7684\u9759\u6001\u68c0\u67e5\u548c\u66f4\u9ad8\u7684\u8fd0\u884c\u65f6\u6027\u80fd\u3002 \u7b80\u5355\u6765\u8bf4&#xff0c;ArkTS \u4e0e TypeScript \u7684\u5173\u7cfb&#xff0c;\u7c7b\u4f3c\u4e8e Swift \u4e0e Objective-C&#xff0c;\u6216\u8005 Kotlin \u4e0e Java\u2014\u2014\u517c\u5bb9\u751f\u6001&#xff0c;\u4f46\u66f4\u4e25\u683c\u3001\u66f4\u73b0\u4ee3\u3001\u66f4\u8d34\u8fd1\u7cfb\u7edf\u5c42\u3002 \u534e\u4e3a\u5b98\u65b9\u5bf9 ArkTS \u7684\u5b9a\u4f4d\u975e\u5e38\u660e\u786e&#xff1a;\u4ece API 9 \u652f\u6301\u58f0\u660e\u5f0f UI&#xff08;ArkUI&#xff09;&#xff0c;\u5230 API 10 \u53ca\u4ee5\u540e\u5f15\u5165\u5f3a\u5236\u9759\u6001\u7c7b\u578b\u3001\u7a7a\u503c\u5b89\u5168\u548c\u5e76\u53d1\u589e\u5f3a&#xff0c;ArkTS \u6b63\u5728\u4ece&#034;\u80fd\u7528\u7684 TS&#034;\u6f14\u8fdb\u4e3a&#034;\u4e3a\u9e3f\u8499\u91cf\u8eab\u5b9a\u5236\u7684\u7cfb\u7edf\u7ea7\u8bed\u8a00&#034;\u3002<\/p>\n<h4>\u4e8c\u3001\u56db\u5927\u6838\u5fc3\u5dee\u5f02&#xff1a;\u522b\u518d\u7528\u5199 TS \u7684\u601d\u7ef4\u5199 ArkTS<\/h4>\n<p>\u5982\u679c\u4f60\u5e26\u7740\u6807\u51c6 TypeScript \u7684\u601d\u7ef4\u76f4\u63a5\u4e0a\u624b ArkTS&#xff0c;IDE \u53ef\u80fd\u4f1a\u62a5\u51fa\u4e00\u5806\u8ba9\u4f60\u56f0\u60d1\u7684\u9519\u8bef\u3002\u4ee5\u4e0b\u662f\u56db\u4e2a\u6700\u5173\u952e\u7684\u663e\u6027\u5dee\u5f02&#xff1a;<\/p>\n<li>\u5f3a\u5236\u9759\u6001\u7c7b\u578b&#xff1a;\u544a\u522b any \u7684\u6e29\u5e8a TypeScript \u7684 any \u662f\u53cc\u5203\u5251&#xff0c;\u5b83\u63d0\u4f9b\u4e86 escape hatch&#xff0c;\u4f46\u4e5f\u8ba9\u7c7b\u578b\u7cfb\u7edf\u5343\u75ae\u767e\u5b54\u3002ArkTS \u5728\u7f16\u8bd1\u671f\u5c31\u7981\u6b62\u9690\u5f0f any&#xff0c;\u8981\u6c42\u6240\u6709\u53d8\u91cf\u3001\u51fd\u6570\u53c2\u6570\u3001\u8fd4\u56de\u503c\u5fc5\u987b\u6709\u660e\u786e\u7684\u7c7b\u578b\u6ce8\u89e3\u3002<\/li>\n<p><span class=\"token comment\">\/\/ TypeScript: \u5141\u8bb8&#xff0c;\u4f46\u4e0d\u63a8\u8350<\/span><br \/>\n<span class=\"token keyword\">function<\/span> <span class=\"token function\">fetchData<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token punctuation\">{<\/span><br \/>\n  <span class=\"token keyword\">return<\/span> <span class=\"token constant\">JSON<\/span><span class=\"token punctuation\">.<\/span><span class=\"token function\">parse<\/span><span class=\"token punctuation\">(<\/span>response<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span> <span class=\"token comment\">\/\/ \u9690\u5f0f any<\/span><br \/>\n<span class=\"token punctuation\">}<\/span><\/p>\n<p><span class=\"token comment\">\/\/ ArkTS: \u7f16\u8bd1\u9519\u8bef&#xff0c;\u5fc5\u987b\u663e\u5f0f\u58f0\u660e<\/span><br \/>\n<span class=\"token keyword\">function<\/span> <span class=\"token function\">fetchData<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span><span class=\"token operator\">:<\/span> UserInfo <span class=\"token punctuation\">{<\/span><br \/>\n  <span class=\"token keyword\">return<\/span> <span class=\"token constant\">JSON<\/span><span class=\"token punctuation\">.<\/span><span class=\"token function\">parse<\/span><span class=\"token punctuation\">(<\/span>response<span class=\"token punctuation\">)<\/span> <span class=\"token keyword\">as<\/span> UserInfo<span class=\"token punctuation\">;<\/span> <span class=\"token comment\">\/\/ \u5fc5\u987b\u7c7b\u578b\u65ad\u8a00\u6216\u663e\u5f0f\u8fd4\u56de\u7c7b\u578b<\/span><br \/>\n<span class=\"token punctuation\">}<\/span><\/p>\n<p>\u4e3a\u4ec0\u4e48\u8fd9\u6837\u8bbe\u8ba1&#xff1f; \u56e0\u4e3a ArkCompiler \u9700\u8981\u5728\u7f16\u8bd1\u671f\u786e\u5b9a\u5185\u5b58\u5e03\u5c40&#xff0c;\u751f\u6210\u9ad8\u6548\u7684\u673a\u5668\u7801\u3002\u5982\u679c\u5b58\u5728\u672a\u77e5\u7684 any \u7c7b\u578b&#xff0c;\u7f16\u8bd1\u5668\u5c31\u65e0\u6cd5\u4f18\u5316\u5c5e\u6027\u8bbf\u95ee\u8def\u5f84&#xff0c;\u53ea\u80fd\u9000\u5316\u4e3a\u6602\u8d35\u7684\u52a8\u6001\u67e5\u627e\u3002<\/p>\n<li>\u5bf9\u8c61\u5e03\u5c40\u51bb\u7ed3&#xff1a;\u8fd0\u884c\u65f6\u4e0d\u8bb8&#034;\u52a0\u620f&#034; \u5728 JavaScript\/TypeScript \u4e2d&#xff0c;\u7ed9\u5bf9\u8c61\u52a8\u6001\u6dfb\u52a0\u5c5e\u6027\u662f\u5bb6\u5e38\u4fbf\u996d&#xff1a;<\/li>\n<p><span class=\"token comment\">\/\/ \u6807\u51c6 TS\/JS<\/span><br \/>\n<span class=\"token keyword\">const<\/span> config <span class=\"token operator\">&#061;<\/span> <span class=\"token punctuation\">{<\/span> name<span class=\"token operator\">:<\/span> <span class=\"token string\">&#034;app&#034;<\/span> <span class=\"token punctuation\">}<\/span><span class=\"token punctuation\">;<\/span><br \/>\nconfig<span class=\"token punctuation\">.<\/span>version <span class=\"token operator\">&#061;<\/span> <span class=\"token string\">&#034;1.0.0&#034;<\/span><span class=\"token punctuation\">;<\/span> <span class=\"token comment\">\/\/ \u5b8c\u5168\u5408\u6cd5<\/span><\/p>\n<p>\u4f46\u5728 ArkTS \u4e2d&#xff0c;\u8fd9\u662f\u4e25\u683c\u7981\u6b62\u7684\u3002\u5bf9\u8c61\u4e00\u65e6\u521b\u5efa&#xff0c;\u5176\u7ed3\u6784&#xff08;shape&#xff09;\u5c31\u88ab\u9501\u5b9a&#xff0c;\u4e0d\u80fd\u65b0\u589e\u6216\u5220\u9664\u5c5e\u6027\u3002\u8fd9\u8981\u6c42\u6211\u4eec\u5fc5\u987b\u9884\u5148\u5b9a\u4e49\u5b8c\u6574\u7684\u63a5\u53e3&#xff1a; \/\/ ArkTS \u6b63\u786e\u5199\u6cd5<\/p>\n<p><span class=\"token keyword\">interface<\/span> <span class=\"token class-name\">AppConfig<\/span> <span class=\"token punctuation\">{<\/span><br \/>\n  name<span class=\"token operator\">:<\/span> <span class=\"token builtin\">string<\/span><span class=\"token punctuation\">;<\/span><br \/>\n  version<span class=\"token operator\">?<\/span><span class=\"token operator\">:<\/span> <span class=\"token builtin\">string<\/span><span class=\"token punctuation\">;<\/span> <span class=\"token comment\">\/\/ \u53ef\u9009\u5c5e\u6027\u5fc5\u987b\u5728\u63a5\u53e3\u58f0\u660e\u9636\u6bb5\u5b9a\u4e49<\/span><br \/>\n<span class=\"token punctuation\">}<\/span><\/p>\n<p><span class=\"token keyword\">const<\/span> config<span class=\"token operator\">:<\/span> AppConfig <span class=\"token operator\">&#061;<\/span> <span class=\"token punctuation\">{<\/span> name<span class=\"token operator\">:<\/span> <span class=\"token string\">&#034;app&#034;<\/span> <span class=\"token punctuation\">}<\/span><span class=\"token punctuation\">;<\/span><br \/>\nconfig<span class=\"token punctuation\">.<\/span>version <span class=\"token operator\">&#061;<\/span> <span class=\"token string\">&#034;1.0.0&#034;<\/span><span class=\"token punctuation\">;<\/span> <span class=\"token comment\">\/\/ \u2705 \u5408\u6cd5&#xff0c;\u56e0\u4e3a\u63a5\u53e3\u5df2\u58f0\u660e<\/span><br \/>\nconfig<span class=\"token punctuation\">.<\/span>author <span class=\"token operator\">&#061;<\/span> <span class=\"token string\">&#034;Tom&#034;<\/span><span class=\"token punctuation\">;<\/span>     <span class=\"token comment\">\/\/ \u274c \u7f16\u8bd1\u9519\u8bef&#xff1a;\u5bf9\u8c61\u4e0a\u6ca1\u6709 author \u5c5e\u6027<\/span><\/p>\n<p>\u8fd9\u79cd\u9650\u5236\u80cc\u540e\u7684\u6280\u672f\u903b\u8f91\u662f\u5355\u4e00\u9690\u85cf\u7c7b\u4f18\u5316&#xff08;monomorphic inline caching&#xff09;\u3002\u56fa\u5b9a\u5bf9\u8c61\u5e03\u5c40\u8ba9 ArkCompiler \u53ef\u4ee5\u4e3a\u5c5e\u6027\u8bbf\u95ee\u751f\u6210\u76f4\u63a5\u5185\u5b58\u504f\u79fb\u6307\u4ee4&#xff0c;\u800c\u4e0d\u662f\u54c8\u5e0c\u67e5\u627e\u3002<\/p>\n<li>\u4e25\u683c\u8fd0\u7b97\u7b26\u8bed\u4e49&#xff1a;\u62d2\u7edd\u9690\u5f0f\u8f6c\u6362 JavaScript \u7684\u9690\u5f0f\u7c7b\u578b\u8f6c\u6362 notoriously \u6df7\u4e71&#xff1a;[] &#043; {}\u30011 &#043; \u201c2\u201d \u7b49\u884c\u4e3a\u5e38\u5e38\u8ba9\u4eba\u56f0\u60d1\u3002ArkTS \u5bf9\u6b64\u8fdb\u884c\u4e86\u4e25\u5389\u6574\u987f&#xff0c;\u9650\u5236\u8fd0\u7b97\u7b26\u53ea\u80fd\u4f5c\u7528\u4e8e\u7279\u5b9a\u7c7b\u578b\u3002 \u6700\u5178\u578b\u7684\u4f8b\u5b50\u662f\u4e00\u5143\u52a0\u53f7 &#043;<\/li>\n<p><span class=\"token comment\">\/\/ TypeScript\/JavaScript<\/span><br \/>\n<span class=\"token keyword\">const<\/span> num <span class=\"token operator\">&#061;<\/span> <span class=\"token operator\">&#043;<\/span><span class=\"token string\">&#034;123&#034;<\/span><span class=\"token punctuation\">;<\/span> <span class=\"token comment\">\/\/ \u5408\u6cd5&#xff0c;\u5b57\u7b26\u4e32\u8f6c\u6570\u5b57<\/span><\/p>\n<p><span class=\"token comment\">\/\/ ArkTS<\/span><br \/>\n<span class=\"token keyword\">const<\/span> num <span class=\"token operator\">&#061;<\/span> <span class=\"token operator\">&#043;<\/span><span class=\"token string\">&#034;123&#034;<\/span><span class=\"token punctuation\">;<\/span> <span class=\"token comment\">\/\/ \u274c \u7f16\u8bd1\u9519\u8bef&#xff1a;\u4e00\u5143\u52a0\u53f7\u53ea\u80fd\u7528\u4e8e number \u7c7b\u578b<\/span><br \/>\n<span class=\"token keyword\">const<\/span> num <span class=\"token operator\">&#061;<\/span> <span class=\"token function\">Number<\/span><span class=\"token punctuation\">(<\/span><span class=\"token string\">&#034;123&#034;<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span> <span class=\"token comment\">\/\/ \u2705 \u5fc5\u987b\u663e\u5f0f\u8f6c\u6362<\/span><\/p>\n<p>\u8fd9\u79cd\u4e25\u683c\u6027\u770b\u4f3c\u589e\u52a0\u4e86\u4ee3\u7801\u91cf&#xff0c;\u5b9e\u5219\u6d88\u9664\u4e86\u5927\u91cf\u6f5c\u5728\u7684\u8fd0\u884c\u65f6 bug&#xff0c;\u540c\u65f6\u4e5f\u8ba9\u7f16\u8bd1\u5668\u80fd\u591f\u751f\u6210\u66f4\u786e\u5b9a\u7684\u6307\u4ee4\u5e8f\u5217\u3002<\/p>\n<li>\u6682\u4e0d\u652f\u6301 Structural Typing TypeScript \u7684\u7ed3\u6784\u7c7b\u578b\u7cfb\u7edf\u8ba9\u6211\u4eec\u53ef\u4ee5\u4eab\u53d7\u9e2d\u5b50\u7c7b\u578b\u7684\u4fbf\u5229&#xff1a;<\/li>\n<p><span class=\"token keyword\">interface<\/span> <span class=\"token class-name\">Point<\/span> <span class=\"token punctuation\">{<\/span> x<span class=\"token operator\">:<\/span> <span class=\"token builtin\">number<\/span><span class=\"token punctuation\">;<\/span> y<span class=\"token operator\">:<\/span> <span class=\"token builtin\">number<\/span><span class=\"token punctuation\">;<\/span> <span class=\"token punctuation\">}<\/span><br \/>\n<span class=\"token keyword\">const<\/span> pt <span class=\"token operator\">&#061;<\/span> <span class=\"token punctuation\">{<\/span> x<span class=\"token operator\">:<\/span> <span class=\"token number\">1<\/span><span class=\"token punctuation\">,<\/span> y<span class=\"token operator\">:<\/span> <span class=\"token number\">2<\/span><span class=\"token punctuation\">,<\/span> z<span class=\"token operator\">:<\/span> <span class=\"token number\">3<\/span> <span class=\"token punctuation\">}<\/span><span class=\"token punctuation\">;<\/span><br \/>\n<span class=\"token keyword\">function<\/span> <span class=\"token function\">draw<\/span><span class=\"token punctuation\">(<\/span>p<span class=\"token operator\">:<\/span> Point<span class=\"token punctuation\">)<\/span> <span class=\"token punctuation\">{<\/span> <span class=\"token operator\">&#8230;<\/span> <span class=\"token punctuation\">}<\/span><br \/>\n<span class=\"token function\">draw<\/span><span class=\"token punctuation\">(<\/span>pt<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span> <span class=\"token comment\">\/\/ TS \u5141\u8bb8&#xff1a;pt \u7ed3\u6784\u517c\u5bb9 Point<\/span><\/p>\n<p>ArkTS \u5f53\u524d\u4e0d\u652f\u6301\u8fd9\u79cd\u57fa\u4e8e\u7ed3\u6784\u76f8\u4f3c\u6027\u7684\u7c7b\u578b\u517c\u5bb9\u3002\u5b83\u91c7\u7528\u540d\u4e49\u7c7b\u578b\u7cfb\u7edf&#xff08;nominal typing&#xff09;&#xff0c;\u7c7b\u578b\u517c\u5bb9\u5fc5\u987b\u901a\u8fc7\u663e\u5f0f\u7684\u7ee7\u627f\u6216\u5b9e\u73b0\u5173\u7cfb\u5efa\u7acb\u3002\u4e0d\u8fc7\u6839\u636e\u534e\u4e3a\u5b98\u65b9\u8def\u7ebf\u56fe&#xff0c;\u5982\u679c\u793e\u533a\u53cd\u9988\u5f3a\u70c8&#xff0c;\u672a\u6765\u7248\u672c\u53ef\u80fd\u4f1a\u91cd\u65b0\u8003\u8651\u652f\u6301 Structural Typing\u3002<\/p>\n<h4>\u4e09\u3001\u5b9e\u6218&#xff1a;\u628a\u4e00\u6bb5 TypeScript \u8fc1\u79fb\u5230 ArkTS<\/h4>\n<p>\u8ba9\u6211\u4eec\u901a\u8fc7\u4e00\u4e2a\u5177\u4f53\u7684\u4f8b\u5b50&#xff0c;\u611f\u53d7\u8fc1\u79fb\u8fc7\u7a0b\u7684\u7ec6\u8282\u3002 \u573a\u666f&#xff1a;\u4e00\u4e2a\u7b80\u5355\u7684\u7528\u6237\u5361\u7247\u7ec4\u4ef6&#xff0c;\u652f\u6301\u52a8\u6001\u6dfb\u52a0\u6807\u7b7e\u3002<\/p>\n<p><span class=\"token comment\">\/\/ \u6807\u51c6 TypeScript \u5199\u6cd5&#xff08;\u6709\u95ee\u9898\u7684 ArkTS \u4ee3\u7801&#xff09;<\/span><br \/>\n<span class=\"token keyword\">class<\/span> <span class=\"token class-name\">UserCard<\/span> <span class=\"token punctuation\">{<\/span><br \/>\n  user<span class=\"token operator\">:<\/span> <span class=\"token builtin\">any<\/span><span class=\"token punctuation\">;<\/span> <span class=\"token comment\">\/\/ \u95ee\u98981&#xff1a;\u9690\u5f0f any<\/span><\/p>\n<p>  <span class=\"token function\">constructor<\/span><span class=\"token punctuation\">(<\/span>data<span class=\"token operator\">:<\/span> <span class=\"token builtin\">any<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token punctuation\">{<\/span><br \/>\n    <span class=\"token keyword\">this<\/span><span class=\"token punctuation\">.<\/span>user <span class=\"token operator\">&#061;<\/span> data<span class=\"token punctuation\">;<\/span><br \/>\n  <span class=\"token punctuation\">}<\/span><\/p>\n<p>  <span class=\"token function\">addTag<\/span><span class=\"token punctuation\">(<\/span>tag<span class=\"token operator\">:<\/span> <span class=\"token builtin\">string<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token punctuation\">{<\/span><br \/>\n    <span class=\"token keyword\">if<\/span> <span class=\"token punctuation\">(<\/span><span class=\"token operator\">!<\/span><span class=\"token keyword\">this<\/span><span class=\"token punctuation\">.<\/span>user<span class=\"token punctuation\">.<\/span>tags<span class=\"token punctuation\">)<\/span> <span class=\"token punctuation\">{<\/span><br \/>\n      <span class=\"token keyword\">this<\/span><span class=\"token punctuation\">.<\/span>user<span class=\"token punctuation\">.<\/span>tags <span class=\"token operator\">&#061;<\/span> <span class=\"token punctuation\">[<\/span><span class=\"token punctuation\">]<\/span><span class=\"token punctuation\">;<\/span> <span class=\"token comment\">\/\/ \u95ee\u98982&#xff1a;\u8fd0\u884c\u65f6\u6539\u53d8\u5bf9\u8c61\u5e03\u5c40<\/span><br \/>\n    <span class=\"token punctuation\">}<\/span><br \/>\n    <span class=\"token keyword\">this<\/span><span class=\"token punctuation\">.<\/span>user<span class=\"token punctuation\">.<\/span>tags<span class=\"token punctuation\">.<\/span><span class=\"token function\">push<\/span><span class=\"token punctuation\">(<\/span>tag<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\n  <span class=\"token punctuation\">}<\/span><br \/>\n<span class=\"token punctuation\">}<\/span><\/p>\n<p><span class=\"token comment\">\/\/ \u4f7f\u7528<\/span><br \/>\n<span class=\"token keyword\">const<\/span> card <span class=\"token operator\">&#061;<\/span> <span class=\"token keyword\">new<\/span> <span class=\"token class-name\">UserCard<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">{<\/span> name<span class=\"token operator\">:<\/span> <span class=\"token string\">&#034;\u5f20\u4e09&#034;<\/span> <span class=\"token punctuation\">}<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\ncard<span class=\"token punctuation\">.<\/span><span class=\"token function\">addTag<\/span><span class=\"token punctuation\">(<\/span><span class=\"token string\">&#034;\u5f00\u53d1\u8005&#034;<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<p>ArkTS \u6b63\u786e\u91cd\u6784&#xff1a;<br \/>\n<span class=\"token comment\">\/\/ 1. \u5b9a\u4e49\u5b8c\u6574\u63a5\u53e3<\/span><br \/>\n<span class=\"token keyword\">interface<\/span> <span class=\"token class-name\">UserInfo<\/span> <span class=\"token punctuation\">{<\/span><br \/>\n  name<span class=\"token operator\">:<\/span> <span class=\"token builtin\">string<\/span><span class=\"token punctuation\">;<\/span><br \/>\n  tags<span class=\"token operator\">?<\/span><span class=\"token operator\">:<\/span> <span class=\"token builtin\">string<\/span><span class=\"token punctuation\">[<\/span><span class=\"token punctuation\">]<\/span><span class=\"token punctuation\">;<\/span> <span class=\"token comment\">\/\/ \u53ef\u9009\u5c5e\u6027\u524d\u7f6e\u58f0\u660e<\/span><br \/>\n<span class=\"token punctuation\">}<\/span><\/p>\n<p><span class=\"token keyword\">class<\/span> <span class=\"token class-name\">UserCard<\/span> <span class=\"token punctuation\">{<\/span><br \/>\n  <span class=\"token comment\">\/\/ 2. \u660e\u786e\u7c7b\u578b&#xff0c;\u7981\u6b62 any<\/span><br \/>\n  user<span class=\"token operator\">:<\/span> UserInfo<span class=\"token punctuation\">;<\/span><\/p>\n<p>  <span class=\"token function\">constructor<\/span><span class=\"token punctuation\">(<\/span>data<span class=\"token operator\">:<\/span> UserInfo<span class=\"token punctuation\">)<\/span> <span class=\"token punctuation\">{<\/span><br \/>\n    <span class=\"token keyword\">this<\/span><span class=\"token punctuation\">.<\/span>user <span class=\"token operator\">&#061;<\/span> data<span class=\"token punctuation\">;<\/span><br \/>\n  <span class=\"token punctuation\">}<\/span><\/p>\n<p>  <span class=\"token function\">addTag<\/span><span class=\"token punctuation\">(<\/span>tag<span class=\"token operator\">:<\/span> <span class=\"token builtin\">string<\/span><span class=\"token punctuation\">)<\/span><span class=\"token operator\">:<\/span> <span class=\"token keyword\">void<\/span> <span class=\"token punctuation\">{<\/span><br \/>\n    <span class=\"token comment\">\/\/ 3. \u521d\u59cb\u5316\u65f6\u786e\u4fdd\u5c5e\u6027\u5b58\u5728&#xff0c;\u6216\u68c0\u67e5\u53ef\u9009\u5c5e\u6027<\/span><br \/>\n    <span class=\"token keyword\">if<\/span> <span class=\"token punctuation\">(<\/span><span class=\"token keyword\">this<\/span><span class=\"token punctuation\">.<\/span>user<span class=\"token punctuation\">.<\/span>tags <span class=\"token operator\">&#061;&#061;&#061;<\/span> <span class=\"token keyword\">undefined<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token punctuation\">{<\/span><br \/>\n      <span class=\"token keyword\">this<\/span><span class=\"token punctuation\">.<\/span>user<span class=\"token punctuation\">.<\/span>tags <span class=\"token operator\">&#061;<\/span> <span class=\"token punctuation\">[<\/span><span class=\"token punctuation\">]<\/span><span class=\"token punctuation\">;<\/span><br \/>\n    <span class=\"token punctuation\">}<\/span><br \/>\n    <span class=\"token keyword\">this<\/span><span class=\"token punctuation\">.<\/span>user<span class=\"token punctuation\">.<\/span>tags<span class=\"token punctuation\">.<\/span><span class=\"token function\">push<\/span><span class=\"token punctuation\">(<\/span>tag<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\n  <span class=\"token punctuation\">}<\/span><br \/>\n<span class=\"token punctuation\">}<\/span><\/p>\n<p><span class=\"token comment\">\/\/ 4. \u4f7f\u7528<\/span><br \/>\n<span class=\"token keyword\">const<\/span> card <span class=\"token operator\">&#061;<\/span> <span class=\"token keyword\">new<\/span> <span class=\"token class-name\">UserCard<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">{<\/span> name<span class=\"token operator\">:<\/span> <span class=\"token string\">&#034;\u5f20\u4e09&#034;<\/span><span class=\"token punctuation\">,<\/span> tags<span class=\"token operator\">:<\/span> <span class=\"token punctuation\">[<\/span><span class=\"token punctuation\">]<\/span> <span class=\"token punctuation\">}<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\ncard<span class=\"token punctuation\">.<\/span><span class=\"token function\">addTag<\/span><span class=\"token punctuation\">(<\/span><span class=\"token string\">&#034;\u5f00\u53d1\u8005&#034;<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<p>\u5173\u952e\u6539\u52a8&#xff1a;\u63d0\u524d\u58f0\u660e tags \u4e3a\u53ef\u9009\u5c5e\u6027&#xff0c;\u521d\u59cb\u5316\u65f6\u63d0\u4f9b\u9ed8\u8ba4\u503c&#xff0c;\u5f7b\u5e95\u6d88\u9664 any\u3002<\/p>\n<h4>\u56db\u3001\u9082\u9005\u58f0\u660e\u5f0f UI&#xff1a;ArkTS \u7684\u9ad8\u5149\u65f6\u523b<\/h4>\n<p>\u9664\u4e86\u8bed\u8a00\u5c42\u9762\u7684\u7ea6\u675f&#xff0c;ArkTS \u6700\u5927\u7684\u6740\u624b\u950f\u662f\u539f\u751f\u652f\u6301\u58f0\u660e\u5f0f UI&#xff08;ArkUI&#xff09;\u3002\u65e0\u9700\u914d\u7f6e React\/Vue&#xff0c;\u65e0\u9700\u6253\u5305 WebView&#xff0c;\u76f4\u63a5\u7528 ArkTS \u8bed\u6cd5\u63cf\u8ff0\u754c\u9762&#xff1a;<\/p>\n<p><span class=\"token decorator\"><span class=\"token at operator\">&#064;<\/span><span class=\"token function\">Entry<\/span><\/span><br \/>\n<span class=\"token decorator\"><span class=\"token at operator\">&#064;<\/span><span class=\"token function\">Component<\/span><\/span><br \/>\nstruct UserPage <span class=\"token punctuation\">{<\/span><br \/>\n  <span class=\"token decorator\"><span class=\"token at operator\">&#064;<\/span><span class=\"token function\">State<\/span><\/span> userName<span class=\"token operator\">:<\/span> <span class=\"token builtin\">string<\/span> <span class=\"token operator\">&#061;<\/span> <span class=\"token string\">&#039;\u5f20\u4e09&#039;<\/span><span class=\"token punctuation\">;<\/span> <span class=\"token comment\">\/\/ \u54cd\u5e94\u5f0f\u72b6\u6001<\/span><br \/>\n  <span class=\"token decorator\"><span class=\"token at operator\">&#064;<\/span><span class=\"token function\">State<\/span><\/span> tags<span class=\"token operator\">:<\/span> <span class=\"token builtin\">string<\/span><span class=\"token punctuation\">[<\/span><span class=\"token punctuation\">]<\/span> <span class=\"token operator\">&#061;<\/span> <span class=\"token punctuation\">[<\/span><span class=\"token string\">&#039;\u5f00\u53d1\u8005&#039;<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token string\">&#039;\u535a\u4e3b&#039;<\/span><span class=\"token punctuation\">]<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<p>  <span class=\"token function\">build<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token punctuation\">{<\/span><br \/>\n    <span class=\"token function\">Column<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">{<\/span> space<span class=\"token operator\">:<\/span> <span class=\"token number\">12<\/span> <span class=\"token punctuation\">}<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token punctuation\">{<\/span><br \/>\n      <span class=\"token function\">Text<\/span><span class=\"token punctuation\">(<\/span><span class=\"token keyword\">this<\/span><span class=\"token punctuation\">.<\/span>userName<span class=\"token punctuation\">)<\/span><br \/>\n        <span class=\"token punctuation\">.<\/span><span class=\"token function\">fontSize<\/span><span class=\"token punctuation\">(<\/span><span class=\"token number\">24<\/span><span class=\"token punctuation\">)<\/span><br \/>\n        <span class=\"token punctuation\">.<\/span><span class=\"token function\">fontWeight<\/span><span class=\"token punctuation\">(<\/span>FontWeight<span class=\"token punctuation\">.<\/span>Bold<span class=\"token punctuation\">)<\/span><\/p>\n<p>      <span class=\"token comment\">\/\/ \u5faa\u73af\u6e32\u67d3\u6807\u7b7e<\/span><br \/>\n      <span class=\"token function\">ForEach<\/span><span class=\"token punctuation\">(<\/span><span class=\"token keyword\">this<\/span><span class=\"token punctuation\">.<\/span>tags<span class=\"token punctuation\">,<\/span> <span class=\"token punctuation\">(<\/span>tag<span class=\"token operator\">:<\/span> <span class=\"token builtin\">string<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token operator\">&#061;&gt;<\/span> <span class=\"token punctuation\">{<\/span><br \/>\n        <span class=\"token function\">TagComponent<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">{<\/span> text<span class=\"token operator\">:<\/span> tag <span class=\"token punctuation\">}<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token comment\">\/\/ \u81ea\u5b9a\u4e49\u7ec4\u4ef6<\/span><br \/>\n      <span class=\"token punctuation\">}<\/span><span class=\"token punctuation\">)<\/span><\/p>\n<p>      <span class=\"token function\">Button<\/span><span class=\"token punctuation\">(<\/span><span class=\"token string\">&#039;\u6dfb\u52a0\u6807\u7b7e&#039;<\/span><span class=\"token punctuation\">)<\/span><br \/>\n        <span class=\"token punctuation\">.<\/span><span class=\"token function\">onClick<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token operator\">&#061;&gt;<\/span> <span class=\"token punctuation\">{<\/span><br \/>\n          <span class=\"token keyword\">this<\/span><span class=\"token punctuation\">.<\/span>tags<span class=\"token punctuation\">.<\/span><span class=\"token function\">push<\/span><span class=\"token punctuation\">(<\/span><span class=\"token string\">&#039;\u65b0\u6807\u7b7e&#039;<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span> <span class=\"token comment\">\/\/ \u72b6\u6001\u53d8\u66f4\u81ea\u52a8\u89e6\u53d1 UI \u66f4\u65b0<\/span><br \/>\n        <span class=\"token punctuation\">}<\/span><span class=\"token punctuation\">)<\/span><br \/>\n    <span class=\"token punctuation\">}<\/span><br \/>\n    <span class=\"token punctuation\">.<\/span><span class=\"token function\">padding<\/span><span class=\"token punctuation\">(<\/span><span class=\"token number\">20<\/span><span class=\"token punctuation\">)<\/span><br \/>\n    <span class=\"token punctuation\">.<\/span><span class=\"token function\">backgroundColor<\/span><span class=\"token punctuation\">(<\/span><span class=\"token string\">&#039;#f5f5f5&#039;<\/span><span class=\"token punctuation\">)<\/span><br \/>\n  <span class=\"token punctuation\">}<\/span><br \/>\n<span class=\"token punctuation\">}<\/span><\/p>\n<p>\u8fd9\u91cc\u7684 &#064;State \u88c5\u9970\u5668\u5b9e\u73b0\u4e86 MVVM \u7684\u54cd\u5e94\u5f0f\u7ed1\u5b9a&#xff0c;\u72b6\u6001\u53d8\u66f4\u4f1a\u81ea\u52a8\u9a71\u52a8 UI \u5237\u65b0&#xff0c;\u4e14\u7531\u4e8e ArkTS \u7684\u9759\u6001\u7c7b\u578b\u4fdd\u8bc1&#xff0c;\u7f16\u8bd1\u5668\u53ef\u4ee5\u5728\u7f16\u8bd1\u671f\u5c31\u4f18\u5316\u7ec4\u4ef6\u7684\u66f4\u65b0\u7b56\u7565\u3002<\/p>\n<h4>\u4e94\u3001\u5f00\u53d1\u73af\u5883&#xff1a;DevEco Studio \u7684\u5feb\u901f\u4e0a\u624b<\/h4>\n<p>\u8981\u5f00\u59cb ArkTS \u5f00\u53d1&#xff0c;\u4f60\u9700\u8981&#xff1a;<\/p>\n<li>\u5b89\u88c5 DevEco Studio&#xff1a;\u534e\u4e3a\u5b98\u65b9\u57fa\u4e8e IntelliJ IDEA \u7684 IDE&#xff0c;\u5185\u7f6e ArkTS \u7f16\u8bd1\u5668\u548c\u5b8c\u6574\u7684\u9e3f\u8499\u6a21\u62df\u5668\u3002<\/li>\n<li>\u914d\u7f6e SDK&#xff1a;\u5728 IDE \u4e2d\u4e0b\u8f7d HarmonyOS SDK&#xff0c;\u76ee\u524d\u4e3b\u6d41\u5f00\u53d1\u7248\u672c\u662f API 9\/10\/11\u3002<\/li>\n<li>\u521b\u5efa Stage \u6a21\u578b\u9879\u76ee&#xff1a;\u9009\u62e9 \u201cEmpty Ability\u201d \u6a21\u677f&#xff0c;\u8bed\u8a00\u9009\u62e9 ArkTS\u3002 IDE \u63d0\u4f9b\u4e86\u5f3a\u5927\u7684\u9884\u89c8\u529f\u80fd&#xff08;Previewer&#xff09;&#xff0c;\u652f\u6301\u4ee3\u7801\u4fee\u6539\u7684\u70ed\u91cd\u8f7d&#xff0c;\u65e0\u9700\u542f\u52a8\u6a21\u62df\u5668\u5373\u53ef\u5b9e\u65f6\u67e5\u770b UI \u6548\u679c&#xff0c;\u8fd9\u5bf9\u524d\u7aef\u5f00\u53d1\u8005\u6765\u8bf4\u4f53\u9a8c\u975e\u5e38\u53cb\u597d\u3002<\/li>\n<h4>\u516d\u3001\u603b\u7ed3&#xff1a;\u503c\u5f97\u6295\u5165\u7684\u65b0\u8d5b\u9053<\/h4>\n<p>\u4ece TypeScript \u5230 ArkTS \u7684\u8fc1\u79fb&#xff0c;\u672c\u8d28\u4e0a\u662f\u4ece&#034;\u7075\u6d3b\u4f18\u5148&#034;\u5411&#034;\u6027\u80fd\u4f18\u5148&#034;\u7684\u601d\u7ef4\u8f6c\u53d8\u3002\u90a3\u4e9b\u770b\u4f3c\u7e41\u7410\u7684\u7ea6\u675f\u2014\u2014\u5f3a\u5236\u7c7b\u578b\u3001\u56fa\u5b9a\u5e03\u5c40\u3001\u4e25\u683c\u8fd0\u7b97\u7b26\u2014\u2014\u6700\u7ec8\u90fd\u4f1a\u8f6c\u5316\u4e3a\u66f4\u5c11\u7684\u8fd0\u884c\u65f6\u5d29\u6e83\u3001\u66f4\u6d41\u7545\u7684\u7528\u6237\u4f53\u9a8c\u548c\u66f4\u4f4e\u7684\u5185\u5b58\u5360\u7528\u3002 \u5bf9\u4e8e\u524d\u7aef\u5f00\u53d1\u8005\u800c\u8a00&#xff0c;ArkTS \u7684\u5b66\u4e60\u66f2\u7ebf\u975e\u5e38\u5e73\u7f13&#xff1a;\u4f60\u4e0d\u9700\u8981\u5b66\u4e60\u5168\u65b0\u7684\u8bed\u6cd5&#xff0c;\u53ea\u9700\u8981\u9002\u5e94\u66f4\u4e25\u683c\u7684\u89c4\u5219&#xff1b;\u540c\u65f6&#xff0c;\u4f60\u53c8\u80fd\u83b7\u5f97\u539f\u751f\u5e94\u7528\u7684\u6027\u80fd\u8868\u73b0\u548c\u58f0\u660e\u5f0f UI \u7684\u5f00\u53d1\u6548\u7387\u3002 \u968f\u7740\u9e3f\u8499\u751f\u6001\u7684\u6269\u5f20&#xff0c;ArkTS \u6b63\u5728\u4ece\u4e00\u4e2a&#034;\u4e13\u7528\u8bed\u8a00&#034;\u9010\u6e10\u8d70\u5411\u66f4\u5e7f\u9614\u7684\u821e\u53f0\u3002\u73b0\u5728\u638c\u63e1\u5b83&#xff0c;\u4e0d\u4ec5\u662f\u591a\u4e86\u4e00\u9879\u6280\u80fd&#xff0c;\u66f4\u662f\u63d0\u524d\u5e03\u5c40\u4e0b\u4e00\u4ee3\u64cd\u4f5c\u7cfb\u7edf\u751f\u6001\u7684\u660e\u667a\u4e4b\u4e3e\u3002 \u4e0b\u4e00\u6b65\u5efa\u8bae&#xff1a;<\/p>\n<li>\u9605\u8bfb\u5b98\u65b9\u300a\u4ece TypeScript \u5230 ArkTS \u7684\u9002\u914d\u89c4\u5219\u300b\u6587\u6863<\/li>\n<li>\u5c1d\u8bd5\u5c06\u4e00\u4e2a\u73b0\u6709\u7684 TypeScript \u5de5\u5177\u51fd\u6570\u91cd\u6784\u4e3a ArkTS \u7248\u672c<\/li>\n<li>\u4f7f\u7528 ArkUI \u5b8c\u6210\u4e00\u4e2a\u5305\u542b\u7f51\u7edc\u8bf7\u6c42\u3001\u5217\u8868\u6e32\u67d3\u3001\u72b6\u6001\u7ba1\u7406\u7684\u5b8c\u6574 Demo \u9e3f\u8499\u4e16\u754c\u7684\u5927\u95e8\u5df2\u7ecf\u655e\u5f00&#xff0c;\u800c\u4f60\u624b\u4e2d\u7684 TypeScript \u7ecf\u9a8c&#xff0c;\u5c31\u662f\u6700\u597d\u7684\u5165\u573a\u5238\u3002<\/li>\n","protected":false},"excerpt":{"rendered":"<p>\u4f5c\u4e3a\u524d\u7aef\u5f00\u53d1\u8005&#xff0c;\u6211\u4eec\u5df2\u7ecf\u4e60\u60ef\u4e86 TypeScript \u5e26\u6765\u7684\u7c7b\u578b\u5b89\u5168\u4e0e\u5f00\u53d1\u6548\u7387\u3002\u4f46\u5f53\u89c6\u7ebf\u8f6c\u5411\u9e3f\u8499\u751f\u6001&#xff08;HarmonyOS&#xff09;\u65f6&#xff0c;\u4e00\u4e2a\u719f\u6089\u53c8\u964c\u751f\u7684\u540d\u5b57\u51fa\u73b0\u4e86\u2014\u2014ArkTS\u3002\u5b83\u770b\u8d77\u6765\u50cf\u6781\u4e86\u6211\u4eec\u719f\u6089\u7684 TS&#xff0c;\u5374\u53c8\u6709\u4e00\u4e9b\\&#8221;\u4e0d\u5408\u5e38\u7406\\&#8221;\u7684\u4e25\u683c\u7ea6\u675f&#xff1a;\u4e0d\u80fd\u968f\u610f\u7ed9\u5bf9\u8c61\u52a0\u5c5e\u6027\u4e86&#xff0c;any \u7c7b\u578b\u88ab\u9650\u5236\u4e86&#xff0c;\u751a\u81f3\u8fde  \u8fd0\u7b97\u7b26\u90fd\u4e0d\u80fd\u968f\u4fbf\u62fc\u63a5\u5b57\u7b26\u4e32\u4e86\u3002 \u8fd9\u5230\u5e95\u662f\u8bed\u8a00\u7684\u5012\u9000&#xff0c;\u8fd8\u662f\u4e3a\u4e86\u6781\u81f4<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[280,568,103],"topic":[],"class_list":["post-70813","post","type-post","status-publish","format-standard","hentry","category-server","tag-harmonyos","tag-typescript","tag-ubuntu"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>TypeScript\u5230ArkTS\uff1a\u9e3f\u8499\u5f00\u53d1\u8005\u7684\u5fc5\u77e5\u5dee\u5f02 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3<\/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.wsisp.com\/helps\/70813.html\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"TypeScript\u5230ArkTS\uff1a\u9e3f\u8499\u5f00\u53d1\u8005\u7684\u5fc5\u77e5\u5dee\u5f02 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"og:description\" content=\"\u4f5c\u4e3a\u524d\u7aef\u5f00\u53d1\u8005&#xff0c;\u6211\u4eec\u5df2\u7ecf\u4e60\u60ef\u4e86 TypeScript \u5e26\u6765\u7684\u7c7b\u578b\u5b89\u5168\u4e0e\u5f00\u53d1\u6548\u7387\u3002\u4f46\u5f53\u89c6\u7ebf\u8f6c\u5411\u9e3f\u8499\u751f\u6001&#xff08;HarmonyOS&#xff09;\u65f6&#xff0c;\u4e00\u4e2a\u719f\u6089\u53c8\u964c\u751f\u7684\u540d\u5b57\u51fa\u73b0\u4e86\u2014\u2014ArkTS\u3002\u5b83\u770b\u8d77\u6765\u50cf\u6781\u4e86\u6211\u4eec\u719f\u6089\u7684 TS&#xff0c;\u5374\u53c8\u6709\u4e00\u4e9b&quot;\u4e0d\u5408\u5e38\u7406&quot;\u7684\u4e25\u683c\u7ea6\u675f&#xff1a;\u4e0d\u80fd\u968f\u610f\u7ed9\u5bf9\u8c61\u52a0\u5c5e\u6027\u4e86&#xff0c;any \u7c7b\u578b\u88ab\u9650\u5236\u4e86&#xff0c;\u751a\u81f3\u8fde \u8fd0\u7b97\u7b26\u90fd\u4e0d\u80fd\u968f\u4fbf\u62fc\u63a5\u5b57\u7b26\u4e32\u4e86\u3002 \u8fd9\u5230\u5e95\u662f\u8bed\u8a00\u7684\u5012\u9000&#xff0c;\u8fd8\u662f\u4e3a\u4e86\u6781\u81f4\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wsisp.com\/helps\/70813.html\" \/>\n<meta property=\"og:site_name\" content=\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"article:published_time\" content=\"2026-02-02T04:58:53+00:00\" \/>\n<meta name=\"author\" content=\"admin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u4f5c\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"admin\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4\" \/>\n\t<meta name=\"twitter:data2\" content=\"3 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/70813.html\",\"url\":\"https:\/\/www.wsisp.com\/helps\/70813.html\",\"name\":\"TypeScript\u5230ArkTS\uff1a\u9e3f\u8499\u5f00\u53d1\u8005\u7684\u5fc5\u77e5\u5dee\u5f02 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"isPartOf\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\"},\"datePublished\":\"2026-02-02T04:58:53+00:00\",\"dateModified\":\"2026-02-02T04:58:53+00:00\",\"author\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/70813.html#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wsisp.com\/helps\/70813.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/70813.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.wsisp.com\/helps\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"TypeScript\u5230ArkTS\uff1a\u9e3f\u8499\u5f00\u53d1\u8005\u7684\u5fc5\u77e5\u5dee\u5f02\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\",\"url\":\"https:\/\/www.wsisp.com\/helps\/\",\"name\":\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"description\":\"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"zh-Hans\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\",\"name\":\"admin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"contentUrl\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"caption\":\"admin\"},\"sameAs\":[\"http:\/\/wp.wsisp.com\"],\"url\":\"https:\/\/www.wsisp.com\/helps\/author\/admin\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"TypeScript\u5230ArkTS\uff1a\u9e3f\u8499\u5f00\u53d1\u8005\u7684\u5fc5\u77e5\u5dee\u5f02 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","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.wsisp.com\/helps\/70813.html","og_locale":"zh_CN","og_type":"article","og_title":"TypeScript\u5230ArkTS\uff1a\u9e3f\u8499\u5f00\u53d1\u8005\u7684\u5fc5\u77e5\u5dee\u5f02 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","og_description":"\u4f5c\u4e3a\u524d\u7aef\u5f00\u53d1\u8005&#xff0c;\u6211\u4eec\u5df2\u7ecf\u4e60\u60ef\u4e86 TypeScript \u5e26\u6765\u7684\u7c7b\u578b\u5b89\u5168\u4e0e\u5f00\u53d1\u6548\u7387\u3002\u4f46\u5f53\u89c6\u7ebf\u8f6c\u5411\u9e3f\u8499\u751f\u6001&#xff08;HarmonyOS&#xff09;\u65f6&#xff0c;\u4e00\u4e2a\u719f\u6089\u53c8\u964c\u751f\u7684\u540d\u5b57\u51fa\u73b0\u4e86\u2014\u2014ArkTS\u3002\u5b83\u770b\u8d77\u6765\u50cf\u6781\u4e86\u6211\u4eec\u719f\u6089\u7684 TS&#xff0c;\u5374\u53c8\u6709\u4e00\u4e9b\"\u4e0d\u5408\u5e38\u7406\"\u7684\u4e25\u683c\u7ea6\u675f&#xff1a;\u4e0d\u80fd\u968f\u610f\u7ed9\u5bf9\u8c61\u52a0\u5c5e\u6027\u4e86&#xff0c;any \u7c7b\u578b\u88ab\u9650\u5236\u4e86&#xff0c;\u751a\u81f3\u8fde \u8fd0\u7b97\u7b26\u90fd\u4e0d\u80fd\u968f\u4fbf\u62fc\u63a5\u5b57\u7b26\u4e32\u4e86\u3002 \u8fd9\u5230\u5e95\u662f\u8bed\u8a00\u7684\u5012\u9000&#xff0c;\u8fd8\u662f\u4e3a\u4e86\u6781\u81f4","og_url":"https:\/\/www.wsisp.com\/helps\/70813.html","og_site_name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","article_published_time":"2026-02-02T04:58:53+00:00","author":"admin","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"admin","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"3 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.wsisp.com\/helps\/70813.html","url":"https:\/\/www.wsisp.com\/helps\/70813.html","name":"TypeScript\u5230ArkTS\uff1a\u9e3f\u8499\u5f00\u53d1\u8005\u7684\u5fc5\u77e5\u5dee\u5f02 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","isPartOf":{"@id":"https:\/\/www.wsisp.com\/helps\/#website"},"datePublished":"2026-02-02T04:58:53+00:00","dateModified":"2026-02-02T04:58:53+00:00","author":{"@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41"},"breadcrumb":{"@id":"https:\/\/www.wsisp.com\/helps\/70813.html#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wsisp.com\/helps\/70813.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.wsisp.com\/helps\/70813.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.wsisp.com\/helps"},{"@type":"ListItem","position":2,"name":"TypeScript\u5230ArkTS\uff1a\u9e3f\u8499\u5f00\u53d1\u8005\u7684\u5fc5\u77e5\u5dee\u5f02"}]},{"@type":"WebSite","@id":"https:\/\/www.wsisp.com\/helps\/#website","url":"https:\/\/www.wsisp.com\/helps\/","name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","description":"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"zh-Hans"},{"@type":"Person","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41","name":"admin","image":{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/","url":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","contentUrl":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","caption":"admin"},"sameAs":["http:\/\/wp.wsisp.com"],"url":"https:\/\/www.wsisp.com\/helps\/author\/admin"}]}},"_links":{"self":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/70813","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/comments?post=70813"}],"version-history":[{"count":0,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/70813\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media?parent=70813"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/categories?post=70813"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/tags?post=70813"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/topic?post=70813"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}