创建特定于平台的 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