Cordova config.xml檔案


這是可以改變應用程式的組態的地方。在上一個教學中建立應用程式時我們設定反向域名和名稱。這值是可以在 config.xml 檔案中更改的。當我們建立應用程式,預設的組態檔案也將被建立。開啟 D:\worksp\cordova\CordovaProject\config.xml 檔案,其程式碼如下:
<?xml version='1.0' encoding='utf-8'?>
<widget id="io.cordova.hellocordova" version="0.0.1" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
    <name>CordovaApp</name>
    <description>
        A sample Apache Cordova application that responds to the deviceready event.
    </description>
    <author email="[email protected]" href="http://cordova.io">
        Apache Cordova Team
    </author>
    <content src="index.html" />
    <plugin name="cordova-plugin-whitelist" spec="1" />
    <access origin="*" />
    <allow-intent href="http://*/*" />
    <allow-intent href="https://*/*" />
    <allow-intent href="tel:*" />
    <allow-intent href="sms:*" />
    <allow-intent href="mailto:*" />
    <allow-intent href="geo:*" />
    <platform name="android">
        <allow-intent href="market:*" />
    </platform>
    <platform name="ios">
        <allow-intent href="itms:*" />
        <allow-intent href="itms-apps:*" />
    </platform>
</widget>

下表說明 config.xml 組態每個元素。

config.xml組態表

元素 詳細
widget
在建立應用程式時指定的應用程式反向域值
name
在建立應用程式時指定的應用程式的名稱
description
應用程式的說明
author 應用程式的作者
content
應用程式的開始頁面。它放在 www 目錄內
plugin
目前已安裝的外掛
access 用於控制存取到外部域。預設原始值被設定為*,它表示允許存取的任何域。 此值不會允許某些特定的URL被開啟,主要用以保護資訊
allow-intent 可讓特定網址要求的應用程式開啟。 例如, <allow-intent href = "tel:*" /> 將允許電話:連結開啟撥號程式
platform
用於構建應用程式的平台