1.鍒濆鍖栭」鐩瓹reateaprojectusingreact-nativescaffolding鍒涘缓涓€涓悕涓簉n-demo鐨勯」鐩紝浣跨敤瀹樻柟鐨則ypescript妯℃澘銆俷pxreact-nativeinitrn_demo--templatereact-native-template-typescript娉ㄦ剰锛氶」鐩悕涓嶈兘浣跨敤-瀛楃锛岃剼鎵嬫灦涓嶆敮鎸併€傝繍琛岄」鐩畒arnios鎴杫arnandroid鍒涘缓濡備笅鍥炬墍绀虹殑鏂囦欢锛氭帴涓嬫潵锛屼负src/utils璺緞閰嶇疆涓€涓埆鍚嶃€?.缂栬緫tsconfig.json璁剧疆鍒悕锛岃В鏋?ts鍜?tsx瀵煎叆鏂囦欢鏃剁殑璺緞鍒悕銆倇"extends":"@tsconfig/react-native/tsconfig.json",/*鎺ㄨ崘ReactNativeTSConfig鍩虹*/"compilerOptions":{/*璁块棶https://aka.ms/tsconfig.json闃呰鏇村鍏充簬杩欎釜鏂囦欢*//*瀹屾暣鎬?/"skipLibCheck":true,/*璺宠繃鎵€鏈?d.ts鏂囦欢鐨勭被鍨嬫鏌ャ€?//*閰嶇疆鍩烘湰URL*/"baseUrl":".",/*閰嶇疆璺緞鍒悕*/"paths":{"*":["src/*"],}}}3.娣诲姞babel鎻掍欢-inbabel-plugin-module-resolver鐢ㄤ簬babel鎵撳寘鏃惰В鏋愯矾寰勫埆鍚嶃€傚鏋滀笉閰嶇疆锛岃繍琛岃繃绋嬩細鎶ラ敊锛屾壘涓嶅埌鏂囦欢銆倅arnadd-Dbabel-plugin-module-resolvereditbabel.config.js閰嶇疆鎻掍欢module.exports={presets:['module:metro-react-native-babel-preset'],plugins:[['module-resolver',{root:['./src'],extensions:['.ios.js','.android.js','.js','.ts','.tsx','.json'],鍒悕:{'*':['./src'],},},],],};4.楠岃瘉骞朵慨鏀笰pp.tsx浠ョ紪鍐欐祴璇曚唬鐮侊細importReactfrom'react';import{SafeAreaView,StyleSheet,Text}from'react-native';importmultiplyfrom'utils/multiply';//浣跨敤鍒悕瀵煎叆妯″潡constApp=()=>{return(
