zoukankan      html  css  js  c++  java
  • apicloud 初学

    html5:在创建html时为了防止页面缩放等不兼容效果,要创建个viewport 
    <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0"/>

    在IOS设备上,有时会将数字转为手机号,这里也要禁止下

    <meta name="format-detection" content="telephone=no"/>

    config  !!

    http://docs.apicloud.com/APICloud/%E6%8A%80%E6%9C%AF%E4%B8%93%E9%A2%98/app-config-manual

    创建云数据库 并 CRUD

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    var model = api.require('model');
                model.config({
                    appKey : 'DCF82DEA-C570-1951-CD56-A55D65835C2D',
                    host : 'https://d.apicloud.com'
                });
                model.insert({
                    class : 'ali',
                    value : {
                        fuck : '值'
                    }
                }, function(ret, err) {
                    if (ret) {
                        //do something
                    }
                });

    前提是 在后台 database中 输入 相关..

    keyvalue 本地

    $api.setStorage('name','key');//设置
    $api.getStorage('name');//获得指定name的值
    $api.rmStorage('name');//清除指定name的值
    $api.clearStorage();//清楚全部本地数据

    本地文件

    var cacheDir = api.cacheDir;
    api.writeFile({
        path: cacheDir+'/自定一个文件名.json',
        data: JSON.stringify(josn)
    }, function(ret, err){

    })

     

    注意要将json转为字符串,否则无法写入,(不转换的话安卓设备可以写入,IOS上是不行的)

     

    ----------------------------------------

    读取:
    api.readFile({
        path: cacheDir+'/文件名.json'
    }, function(ret, err){
        if(ret.status){
            var jsonData = JSON.parse(ret.data);
        }
    });

    注意读的时候将数据转为对象

     

    api.ajax({
            url: serverUrl + url,
            method: method,
            cache: false,
            timeout: 30,
            dataType: 'json',
            data: {
                values: datas
            }
        }, function (ret, err) {
            callBack(ret, err);
        });

     

  • 相关阅读:
    例7-13
    例7-11
    例7-1
    例6-5
    例6-3
    例6-2
    例6-1
    例5-9
    例5-8
    例5-7
  • 原文地址:https://www.cnblogs.com/aliblogs/p/5493680.html
Copyright © 2011-2022 走看看