|
本帖最后由 uoaccw 于 2017-12-22 01:25 编辑
1. 新建webAPP。
2. 添加要使用的模块。
3. 修改自己服务器上的网页代码,调用模块。
4. 填写网址,云编译APP。
通过调用APICloud原生模块和api 的方法,提高了web页面访问手机系统接口的能力,增强了我们APP的功能。
需要注意的地方:
1. api对象的调用要写在apiready里面。
2. 有些模块需要配置config.xml文件,webAPP不能配置config.xml, 因此如果要使用这类模块,建议在网站上新建APP时选择nativeAPP。
- <!DOCTYPE html>
- <html>
- <head>
- <meta charset="utf-8">
- <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0" />
- <title>title</title>
- <style>
- * {
- margin: 0;
- padding: 0;
- }
- html,
- body {
- background-color: #fff;
- }
- div {
- display: -moz-flex;
- display: -webkit-flex;
- display: flex;
- width: 100%;
- height: 100px;
- -moz-justify-content: center;
- -moz-align-items: center;
- -webkit-justify-content: center;
- -webkit-align-items: center;
- justify-content: center;
- align-items: center;
- }
- button {
- background-color: #fff;
- border: 1px solid #333;
- }
- img {
- position: relative;
- left: 10%;
- top: 10%;
- }
- </style>
- </head>
- <body>
- <div>
- <button type="button" onclick="FNPhotograph_open()" name="button">拍照</button>
- </div>
- <img id="img" src="" width="260" he alt="图片" />
- </body>
- <script type="text/javascript">
- var FNPhotograph;
- apiready = function() {
- FNPhotograph = api.require('FNPhotograph');
- };
- function FNPhotograph_open() {
- FNPhotograph.open({
- path: 'fs://savePath',
- album: true,
- quality: 'medium'
- }, function(ret) {
- if (ret && ret.imagePath) {
- document.getElementById('img').src = ret.imagePath;
- FNPhotograph.close();
- }
- });
- }
- </script>
- </html>
复制代码
|
本帖子中包含更多资源,您需要 登录 才可以下载或查看,没有帐号?立即注册
X
|