帖子
帖子
用户
博客
课程
12下一页
返回列表 发新帖
显示全部楼层
67
帖子
0
勋章
974
Y币

webAPP使用模块教程

[复制链接]
发表于 2017-12-21 18:47:14
本帖最后由 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。




  1. <!DOCTYPE html>
  2. <html>

  3. <head>
  4.     <meta charset="utf-8">
  5.     <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0" />
  6.     <title>title</title>

  7.     <style>
  8.         * {
  9.             margin: 0;
  10.             padding: 0;
  11.         }

  12.         html,
  13.         body {
  14.             background-color: #fff;
  15.         }

  16.         div {
  17.             display: -moz-flex;
  18.             display: -webkit-flex;
  19.             display: flex;
  20.             width: 100%;
  21.             height: 100px;
  22.             -moz-justify-content: center;
  23.             -moz-align-items: center;
  24.             -webkit-justify-content: center;
  25.             -webkit-align-items: center;
  26.              justify-content: center;
  27.             align-items: center;
  28.         }

  29.         button {
  30.             background-color: #fff;
  31.             border: 1px solid #333;
  32.         }

  33.         img {
  34.             position: relative;
  35.             left: 10%;
  36.             top: 10%;
  37.         }
  38.     </style>
  39. </head>

  40. <body>
  41.     <div>
  42.         <button type="button" onclick="FNPhotograph_open()" name="button">拍照</button>
  43.     </div>
  44.     <img id="img" src="" width="260" he alt="图片" />
  45. </body>
  46. <script type="text/javascript">
  47.     var FNPhotograph;
  48.     apiready = function() {
  49.         FNPhotograph = api.require('FNPhotograph');
  50.     };

  51.     function FNPhotograph_open() {
  52.         FNPhotograph.open({
  53.             path: 'fs://savePath',
  54.             album: true,
  55.             quality: 'medium'
  56.         }, function(ret) {
  57.             if (ret && ret.imagePath) {
  58.                 document.getElementById('img').src = ret.imagePath;
  59.                 FNPhotograph.close();
  60.             }
  61.         });
  62.     }
  63. </script>

  64. </html>
复制代码

本帖子中包含更多资源,您需要 登录 才可以下载或查看,没有帐号?立即注册

X
5
帖子
0
勋章
3759
Y币
感谢分享
1682
帖子
10
勋章
3759
Y币
感谢分享
2
帖子
0
勋章
2271
Y币
感谢分享。
9
帖子
0
勋章
43
Y币
请问一下,从哪里看某些模块需要在config.xml配置呢?db模块需要吗?
3
帖子
0
勋章
4582
Y币
ha-ha 发表于 2018-1-16 20:03
请问一下,从哪里看某些模块需要在config.xml配置呢?db模块需要吗?

DB模块直接在云端模块里添加模块,不需要在config里配置
3
帖子
0
勋章
17
Y币
请问webApp  调用手机原生方法,需要在服务器的网页中引用api.js吗?
非常感谢您的帮助!!!!
67
帖子
0
勋章
974
Y币
河鱼 发表于 2018-11-3 16:59
请问webApp  调用手机原生方法,需要在服务器的网页中引用api.js吗?

不需要
1
帖子
0
勋章
9
Y币
可以帮我弄下苹果CMS吗
12下一页
您需要登录后才可以回帖 登录

本版积分规则