APICloud开发小技巧(二)

1、apicloud中 json、字符串之间的互转

$api.jsonToStr(ret);
$api.strToJson(ret)

 2、页面的来回跳转

例如已经打开了一个页面,跳转走,改变数据在跳转回来,这个时候数据是默认不变化的打开的是历史,想要清除历史

api.openWin({
            name : 'addAddress',
            url : '../main/addAddress.html',
            bounces : false,
            animation : {
                type : "push",
                duration : 300
            },
            reload: true,
            pageParam : {
                cartIds : cartIds
            }

        });

frame 和 window 打开的时候都加上:

reload: true,
3、开发中经常遇到后端传来的数据是代码片段这时候就要用到转义了
{{@detail.content}}

 4、根据点击的元素查找父元素

function chooseItem(obj){
        var ele = $api.closest(obj, '.list_gui');
        var selectList = $api.domAll(ele, '.tapmLi');
        for(var i = 0; i < selectList.length; i++){
            $api.removeCls(selectList[i], 'active');
        }
        $api.addCls(obj, 'active');
    }

 5、打开frame

apicloud可以直接打开特定frame。但是frame组是不行的。有的时候需要打开特定的frame组里面的一个frame

api.setFrameGroupIndex({
        name: 'group',
        ndex: 0
});
 
原文地址:https://www.cnblogs.com/haonanZhang/p/8779031.html