Cordova打包服务端页面
环境配置
下载最新的nodejs
配置你想打包的平台环境,本人配置了Android的开发环境,具体方法参考中国官网
创建项目
打开命令行或终端
// 设置淘宝代理
npm config set registry " https://registry.npm.taobao.org "
// 安装Cordova
npm i cordova -g
// 创建项目
cordova create baidu
cd baidu
// 添加Android平台
cordova platform add android
更改config.xml配置
配置文件更具需求修改。
<?xml version='1.0' encoding='utf-8'?>
<!-- id: App包名,一般格式为域名反序 + 项目名,示例:com.sunmoon.ceshi-->
<widget id="io.cordova.baidu" version="1.0.0" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
<!-- App名称 -->
<name>百度Cordova</name>
<description>
你的应用描述
</description>
<!-- 作者信息 -->
<author email="dev@cordova.apache.org" href="http://cordova.io">
Apache Cordova Team
</author>
<!-- 加载地址,默认为index.html,将其修改成app的入口网址。 -->
<content src="https://www.baidu.com" />
<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:*" />
<!-- 允许打开外部链接,这里设置允许所有https链接 -->
<allow-navigation href="https://*/*" />
<platform name="android">
<allow-intent href="market:*" />
</platform>
<platform name="ios">
<allow-intent href="itms:*" />
<allow-intent href="itms-apps:*" />
</platform>
<engine name="android" spec="^7.0.0" />
</widget>
运行
// 运行
cordova run android