从统一存储删除一个数据
AlipayJSBridge.call('removeAPDataStorage', {
type: "common",
business: "customBusinessKey",
key: "customKey",
}, function(result) {
alert(JSON.stringify(result));
});
<button id="J_saveDataBtn" class="btn">保存数据</button>
<button id="J_getDataBtn" class="btn">查看数据</button>
<button id="J_removeDataBtn" class="btn">删除数据</button>
<script>
function ready(callback) {
// 如果jsbridge已经注入则直接调用
if (window.AlipayJSBridge) {
callback && callback();
} else {
// 如果没有注入则监听注入的事件
document.addEventListener('AlipayJSBridgeReady', callback, false);
}
}
ready(function() {
document.querySelector('#J_saveDataBtn').addEventListener('click', function(e) {
AlipayJSBridge.call('setAPDataStorage', {
type: "common",
business: "customBusinessKey",
key: "customKey",
value: "customValue"
}, function(result) {
alert(JSON.stringify(result));
});
}, false);
document.querySelector('#J_getDataBtn').addEventListener('click', function(e) {
AlipayJSBridge.call('getAPDataStorage', {
type: "common",
business: "customBusinessKey",
key: "customKey"
}, function(result) {
alert(JSON.stringify(result));
});
}, false);
document.querySelector('#J_removeDataBtn').addEventListener('click', function(e) {
AlipayJSBridge.call('removeAPDataStorage', {
type: "common",
business: "customBusinessKey",
key: "customKey"
}, function(result) {
alert(JSON.stringify(result));
});
}, false);
}, false);
</script>
AlipayJSBridge.call('removeAPDataStorage', {
type, business, key
});
名称 | 类型 | 描述 | 必选 | 默认值 | 版本 |
---|---|---|---|---|---|
type | string | (user/common) 用户维度存储还是公共存储,默认值common | N | ‘common’ | |
business | string | 自定义的业务标识,可与相应的客户端存取代码约定。默认值:”NebulaBiz” | N | ‘’ | |
key | string | 自定义数据的key | Y | ‘’ |
回调函数带入的参数result: {success}
名称 | 类型 | 描述 |
---|---|---|
success | bool | 删除是否成功 |