1. 程式人生 > >一、APICloud程式碼結構解析

一、APICloud程式碼結構解析

一、入口檔案載入與跳轉的頁面(頁面之間傳值)

<!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"/>
    <meta name="format-detection" content="telephone=no,email=no,date=no,address=no"
>
<title>Hello APP</title> <link rel="stylesheet" type="text/css" href="./css/api.css" /> <style type="text/css"></style> </head> <body> </body> <script type="text/javascript" src="./script/api.js"></script> <script type="text/javascript"
>
apiready = function(){ api.openWin({ name: 'main', url: './html/main.html', pageParam: { name: 'test' //這裡是引數的傳遞,在另一頁面接受 } }); }; </script> </html>

二、載入main頁面

<!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"/> <meta name="format-detection" content="telephone=no,email=no,date=no,address=no"> <title>Hello APP</title> <link rel="stylesheet" type="text/css" href="../css/api.css" /> <style> header { position: relative; width: 100%; height: 60px; background-color: #f0f; } header h1{ position: relative; height:60px; line-height: 80px; font-size: 20px; color: #fff; text-align: center; } header .right { position: absolute; bottom: 0; right:0; width: 100px; height: 60px; line-height: 80px; font-size: 16px; text-align: center; } </style> </head> <body> <header> <h1>每日活動</h1> <div class="right" tapmode onclick="fnOpenpersonCenterWin();">個人中心</div> </header> </body> <script type="text/javascript" src="../script/api.js"></script> <script type="text/javascript"> apiready = function(){ //alert(api.pageParam.name);// 頁面傳值。 }; function fnOpenpersonCenterWin() { api.openWin({ name: 'page1', url: './login.html', pageParam: { name: 'test' } }); } </script> </html>

三、跳轉的頁面

<!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"/>
    <meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
    <title>Hello APP</title>
    <link rel="stylesheet" type="text/css" href="../css/api.css" />
    <style>
    header {
      position: relative;
      width: 100%;
      height: 60px;
      background-color: #f0f;
    }
    header h1{
      position: relative;
      height:60px;
      line-height: 80px;
      font-size: 20px;
      color: #fff;
      text-align: center;
    }

    header .left
    {
      position: absolute;
      bottom: 0;
      left:0;
      width: 100px;
      height: 60px;
      line-height: 80px;
      font-size: 16px;
      text-align: center;
    }

    header .right
    {
      position: absolute;
      bottom: 0;
      right:0;
      width: 100px;
      height: 60px;
      line-height: 80px;
      font-size: 16px;
      text-align: center;
    }

    </style>
</head>
<body>
  <header>
      <h1>登陸</h1>
    <div class="left" tapmode onclick="api.closeWin();">返回</div>
    <div class="right" tapmode onclick="fnOpenRegisterWin();">註冊</div>
  </header>
</body>
<script type="text/javascript" src="../script/api.js"></script>
<script type="text/javascript">
    apiready = function(){

    };
    function fnOpenRegisterWin()
    {
      api.openWin({
          name: 'register',
          url: './register.html',
          pageParam: {
              name: 'test'
          }
      });

    }
</script>
</html>

四、註冊頁面

<!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"/>
    <meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
    <title>Hello APP</title>
    <link rel="stylesheet" type="text/css" href="../css/api.css" />
    <style>
    header {
      position: relative;
      width: 100%;
      height: 60px;
      background-color: #f0f;
    }
    header h1{
      position: relative;
      height:60px;
      line-height: 80px;
      font-size: 20px;
      color: #fff;
      text-align: center;
    }

    header .left
    {
      position: absolute;
      bottom: 0;
      left:0;
      width: 100px;
      height: 60px;
      line-height: 80px;
      font-size: 16px;
      text-align: center;
    }
    </style>
</head>
<body>
  <header>
      <h1>登陸</h1>
    <div class="left" tapmode onclick="api.closeWin();">返回</div>

  </header>
</body>
<script type="text/javascript" src="../script/api.js"></script>
<script type="text/javascript">
    apiready = function(){
    };
</script>
</html>

——————————————————————————————————————————
**開啟**frame
這裡寫圖片描述

<!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"/>
    <meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
    <title>Hello APP</title>
    <link rel="stylesheet" type="text/css" href="../css/api.css" />
    <style>
    header {
      position: relative;
      width: 100%;
      height: 60px;
      background-color: #f0f;
    }
    header h1{
      position: relative;
      height:60px;
      line-height: 80px;
      font-size: 20px;
      color: #fff;
      text-align: center;
    }

    header .left
    {
      position: absolute;
      bottom: 0;
      left:0;
      width: 100px;
      height: 60px;
      line-height: 80px;
      font-size: 16px;
      text-align: center;
    }


    header .right
    {
      position: absolute;
      bottom: 0;
      right:0;
      width: 100px;
      height: 60px;
      line-height: 80px;
      font-size: 16px;
      text-align: center;
    }

    </style>
</head>
<body>
  <header>
      <h1>每日活動</h1>
    <div class="left" tapmode onclick="fnOpenframe();">frmae</div>
    <div class="right" tapmode onclick="fnOpenpersonCenterWin();">個人中心</div>
  </header>
</body>
<script type="text/javascript" src="../script/api.js"></script>
<script type="text/javascript">
    apiready = function(){

    };
    function fnOpenframe(){
      api.openFrame({
          name: 'frame',
          url: './frame.html',
          rect: {
              x: 0,
              y: 60,
              w: 'auto',
              h: 'auto'
          },
          pageParam: {
              name: 'test'
          },
          bounces: true,
          bgColor: 'rgba(0,0,0,0)',
          vScrollBarEnabled: true,
          hScrollBarEnabled: true
      });

    }
    function fnOpenpersonCenterWin()
    {
      api.openWin({
          name: 'page1',
          url: './login.html',
          pageParam: {
              name: 'test'
          }
      });

    }
</script>
</html>
<!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"/>
    <meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
    <title>Hello APP</title>
    <link rel="stylesheet" type="text/css" href="../css/api.css" />
    <style>
    html,body {
      height: 100%;
      background-color: rgba(0, 0, 0, 0.5);
    }

    </style>
</head>
<body>

</body>
<script type="text/javascript" src="../script/api.js"></script>
<script type="text/javascript"></script>
</html>