建立特定於平臺的 cssjs(androidios)

假設你要建立特定於平臺的 css / js 檔案。為此,你必須在 cordova 專案的根資料夾中建立合併資料夾。在 merges 資料夾中為每個平臺建立目錄(android / ios ..)。然後在特定的平臺資料夾中建立一個 css / js 資料夾,並將你的 css / js 檔案特定於 platform 資料夾。就是這樣,一旦你執行 cordova build 命令,對應於每個平臺的所有 js / css 檔案都將被放置在受尊重的平臺資料夾中

注意: 確保你的根 www / index.html 將定義相同的 css / js。為此,請確保你在 merges 資料夾中具有與每個平臺相對應的相同檔名。

//let say you are in CordovaMergesExample folder
cd CordovaMergesExample 

//create test folder with com.test id and TestApp as name
cordova create test com.test TestApp

//add platform android and ios 
cordova platform add android ios

//create merges/android/css/override.css and merges/ios/css/override.css 

//In root www/index.html add this stylesheet
<link rel="stylesheet" type="text/css" href="css/override.css" />

cordova build

---> cordova build engine automatically identify the platform in merges folder and add files in respective folders. Check platforms/android/assets/www/css and platforms/ios/www/css