1# 轻量级存储<a name="ZH-CN_TOPIC_0000001163812238"></a> 2 3轻量级数据库为应用提供key-value键值型的文件数据处理能力,支持应用对数据进行轻量级存储及查询。数据存储形式为键值对,键的类型为字符串型,值的存储数据类型包括数字型、字符型、布尔型。 4 5## 导入模块<a name="zh-cn_topic_0000001117163542_s56d19203690d4782bfc74069abb6bd71"></a> 6 7``` 8import data_storage from '@ohos.data.storage'; 9``` 10 11## 权限<a name="zh-cn_topic_0000001117163542_section11257113618419"></a> 12 13无 14 15## 属性<a name="zh-cn_topic_0000001117163542_section7299123218370"></a> 16 17<a name="zh-cn_topic_0000001117163542_table1540155452420"></a> 18<table><thead align="left"><tr id="zh-cn_topic_0000001117163542_row1947713549244"><th class="cellrowborder" valign="top" width="21.86%" id="mcps1.1.6.1.1"><p id="zh-cn_topic_0000001117163542_p74771754102410"><a name="zh-cn_topic_0000001117163542_p74771754102410"></a><a name="zh-cn_topic_0000001117163542_p74771754102410"></a>名称</p> 19</th> 20<th class="cellrowborder" valign="top" width="11.15%" id="mcps1.1.6.1.2"><p id="zh-cn_topic_0000001117163542_p1047755412411"><a name="zh-cn_topic_0000001117163542_p1047755412411"></a><a name="zh-cn_topic_0000001117163542_p1047755412411"></a>参数类型</p> 21</th> 22<th class="cellrowborder" valign="top" width="9.34%" id="mcps1.1.6.1.3"><p id="zh-cn_topic_0000001117163542_p34782054192412"><a name="zh-cn_topic_0000001117163542_p34782054192412"></a><a name="zh-cn_topic_0000001117163542_p34782054192412"></a>可读</p> 23</th> 24<th class="cellrowborder" valign="top" width="11.62%" id="mcps1.1.6.1.4"><p id="zh-cn_topic_0000001117163542_p1847865452413"><a name="zh-cn_topic_0000001117163542_p1847865452413"></a><a name="zh-cn_topic_0000001117163542_p1847865452413"></a>可写</p> 25</th> 26<th class="cellrowborder" valign="top" width="46.03%" id="mcps1.1.6.1.5"><p id="zh-cn_topic_0000001117163542_p12478954132419"><a name="zh-cn_topic_0000001117163542_p12478954132419"></a><a name="zh-cn_topic_0000001117163542_p12478954132419"></a>说明</p> 27</th> 28</tr> 29</thead> 30<tbody><tr id="zh-cn_topic_0000001117163542_row1247811541240"><td class="cellrowborder" valign="top" width="21.86%" headers="mcps1.1.6.1.1 "><p id="zh-cn_topic_0000001117163542_p51525360147"><a name="zh-cn_topic_0000001117163542_p51525360147"></a><a name="zh-cn_topic_0000001117163542_p51525360147"></a>MAX_KEY_LENGTH</p> 31</td> 32<td class="cellrowborder" valign="top" width="11.15%" headers="mcps1.1.6.1.2 "><p id="zh-cn_topic_0000001117163542_p9478135414243"><a name="zh-cn_topic_0000001117163542_p9478135414243"></a><a name="zh-cn_topic_0000001117163542_p9478135414243"></a>string</p> 33</td> 34<td class="cellrowborder" valign="top" width="9.34%" headers="mcps1.1.6.1.3 "><p id="zh-cn_topic_0000001117163542_p1247885492411"><a name="zh-cn_topic_0000001117163542_p1247885492411"></a><a name="zh-cn_topic_0000001117163542_p1247885492411"></a>是</p> 35</td> 36<td class="cellrowborder" valign="top" width="11.62%" headers="mcps1.1.6.1.4 "><p id="zh-cn_topic_0000001117163542_p3478054192416"><a name="zh-cn_topic_0000001117163542_p3478054192416"></a><a name="zh-cn_topic_0000001117163542_p3478054192416"></a>否</p> 37</td> 38<td class="cellrowborder" valign="top" width="46.03%" headers="mcps1.1.6.1.5 "><p id="zh-cn_topic_0000001117163542_p12478654172415"><a name="zh-cn_topic_0000001117163542_p12478654172415"></a><a name="zh-cn_topic_0000001117163542_p12478654172415"></a>key的最大长度限制,大小为80字节。</p> 39</td> 40</tr> 41<tr id="zh-cn_topic_0000001117163542_row184789546249"><td class="cellrowborder" valign="top" width="21.86%" headers="mcps1.1.6.1.1 "><p id="zh-cn_topic_0000001117163542_p1971014525154"><a name="zh-cn_topic_0000001117163542_p1971014525154"></a><a name="zh-cn_topic_0000001117163542_p1971014525154"></a>MAX_VALUE_LENGTH</p> 42</td> 43<td class="cellrowborder" valign="top" width="11.15%" headers="mcps1.1.6.1.2 "><p id="zh-cn_topic_0000001117163542_p1392172791820"><a name="zh-cn_topic_0000001117163542_p1392172791820"></a><a name="zh-cn_topic_0000001117163542_p1392172791820"></a>string</p> 44</td> 45<td class="cellrowborder" valign="top" width="9.34%" headers="mcps1.1.6.1.3 "><p id="zh-cn_topic_0000001117163542_p1870905231512"><a name="zh-cn_topic_0000001117163542_p1870905231512"></a><a name="zh-cn_topic_0000001117163542_p1870905231512"></a>是</p> 46</td> 47<td class="cellrowborder" valign="top" width="11.62%" headers="mcps1.1.6.1.4 "><p id="zh-cn_topic_0000001117163542_p137081152141516"><a name="zh-cn_topic_0000001117163542_p137081152141516"></a><a name="zh-cn_topic_0000001117163542_p137081152141516"></a>否</p> 48</td> 49<td class="cellrowborder" valign="top" width="46.03%" headers="mcps1.1.6.1.5 "><p id="zh-cn_topic_0000001117163542_p1470645211154"><a name="zh-cn_topic_0000001117163542_p1470645211154"></a><a name="zh-cn_topic_0000001117163542_p1470645211154"></a>string类型value的最大长度限制,大小为8192字节。</p> 50</td> 51</tr> 52</tbody> 53</table> 54 55## 方法<a name="zh-cn_topic_0000001117163542_section88091318127"></a> 56 57## getStorageSync\(path: string\)<a name="zh-cn_topic_0000001117163542_section172447329132"></a> 58 59读取指定文件,将数据加载到Storage实例,用于数据操作。 60 61此方法为同步方法。 62 63**参数:** 64 65<a name="zh-cn_topic_0000001117163542_table2720134112170"></a> 66<table><thead align="left"><tr id="zh-cn_topic_0000001117163542_row18721041131710"><th class="cellrowborder" valign="top" width="14.82%" id="mcps1.1.5.1.1"><p id="zh-cn_topic_0000001117163542_p19721184111716"><a name="zh-cn_topic_0000001117163542_p19721184111716"></a><a name="zh-cn_topic_0000001117163542_p19721184111716"></a>参数名</p> 67</th> 68<th class="cellrowborder" valign="top" width="14.729999999999999%" id="mcps1.1.5.1.2"><p id="zh-cn_topic_0000001117163542_p672184171715"><a name="zh-cn_topic_0000001117163542_p672184171715"></a><a name="zh-cn_topic_0000001117163542_p672184171715"></a>类型</p> 69</th> 70<th class="cellrowborder" valign="top" width="9.16%" id="mcps1.1.5.1.3"><p id="zh-cn_topic_0000001117163542_p972174116173"><a name="zh-cn_topic_0000001117163542_p972174116173"></a><a name="zh-cn_topic_0000001117163542_p972174116173"></a>必填</p> 71</th> 72<th class="cellrowborder" valign="top" width="61.29%" id="mcps1.1.5.1.4"><p id="zh-cn_topic_0000001117163542_p1372134161712"><a name="zh-cn_topic_0000001117163542_p1372134161712"></a><a name="zh-cn_topic_0000001117163542_p1372134161712"></a>说明</p> 73</th> 74</tr> 75</thead> 76<tbody><tr id="zh-cn_topic_0000001117163542_row11721541121717"><td class="cellrowborder" valign="top" width="14.82%" headers="mcps1.1.5.1.1 "><p id="zh-cn_topic_0000001117163542_p1472154117175"><a name="zh-cn_topic_0000001117163542_p1472154117175"></a><a name="zh-cn_topic_0000001117163542_p1472154117175"></a>path</p> 77</td> 78<td class="cellrowborder" valign="top" width="14.729999999999999%" headers="mcps1.1.5.1.2 "><p id="zh-cn_topic_0000001117163542_p372134110175"><a name="zh-cn_topic_0000001117163542_p372134110175"></a><a name="zh-cn_topic_0000001117163542_p372134110175"></a>string</p> 79</td> 80<td class="cellrowborder" valign="top" width="9.16%" headers="mcps1.1.5.1.3 "><p id="zh-cn_topic_0000001117163542_p19721134101713"><a name="zh-cn_topic_0000001117163542_p19721134101713"></a><a name="zh-cn_topic_0000001117163542_p19721134101713"></a>是</p> 81</td> 82<td class="cellrowborder" valign="top" width="61.29%" headers="mcps1.1.5.1.4 "><p id="zh-cn_topic_0000001117163542_p1068312615010"><a name="zh-cn_topic_0000001117163542_p1068312615010"></a><a name="zh-cn_topic_0000001117163542_p1068312615010"></a>应用程序内部数据存储路径。</p> 83</td> 84</tr> 85</tbody> 86</table> 87 88**返回值:** 89 90<a name="zh-cn_topic_0000001117163542_table372204131719"></a> 91<table><thead align="left"><tr id="zh-cn_topic_0000001117163542_row8722124116175"><th class="cellrowborder" valign="top" width="17.01%" id="mcps1.1.3.1.1"><p id="zh-cn_topic_0000001117163542_p4722041171712"><a name="zh-cn_topic_0000001117163542_p4722041171712"></a><a name="zh-cn_topic_0000001117163542_p4722041171712"></a>类型</p> 92</th> 93<th class="cellrowborder" valign="top" width="82.99%" id="mcps1.1.3.1.2"><p id="zh-cn_topic_0000001117163542_p072234114173"><a name="zh-cn_topic_0000001117163542_p072234114173"></a><a name="zh-cn_topic_0000001117163542_p072234114173"></a>说明</p> 94</th> 95</tr> 96</thead> 97<tbody><tr id="zh-cn_topic_0000001117163542_row4722144111715"><td class="cellrowborder" valign="top" width="17.01%" headers="mcps1.1.3.1.1 "><p id="zh-cn_topic_0000001117163542_p16723164161713"><a name="zh-cn_topic_0000001117163542_p16723164161713"></a><a name="zh-cn_topic_0000001117163542_p16723164161713"></a><a href="#zh-cn_topic_0000001117163542_section12882825611">Storage</a></p> 98</td> 99<td class="cellrowborder" valign="top" width="82.99%" headers="mcps1.1.3.1.2 "><p id="zh-cn_topic_0000001117163542_p12723741161713"><a name="zh-cn_topic_0000001117163542_p12723741161713"></a><a name="zh-cn_topic_0000001117163542_p12723741161713"></a>获取到要操作的Storage实例,用于进行数据库的操作。</p> 100</td> 101</tr> 102</tbody> 103</table> 104 105**示例:** 106 107``` 108const PATH = '/data/accounts/account_0/appdata/com.example.myapplication/database/{storage_name}'; 109let store = data_storage.getStorageSync(PATH); 110``` 111 112## getStorage\(path: string, callback: AsyncCallback<Storage\>\)<a name="zh-cn_topic_0000001117163542_section192192415554"></a> 113 114读取指定文件,将数据加载到Storage实例,用于数据操作。 115 116此方法为异步方法。 117 118**参数:** 119 120<a name="zh-cn_topic_0000001117163542_table69661135912"></a> 121<table><thead align="left"><tr id="zh-cn_topic_0000001117163542_row149668318915"><th class="cellrowborder" valign="top" width="14.451487079473427%" id="mcps1.1.5.1.1"><p id="zh-cn_topic_0000001117163542_p7966738914"><a name="zh-cn_topic_0000001117163542_p7966738914"></a><a name="zh-cn_topic_0000001117163542_p7966738914"></a>参数名</p> 122</th> 123<th class="cellrowborder" valign="top" width="18.95660653339834%" id="mcps1.1.5.1.2"><p id="zh-cn_topic_0000001117163542_p296713699"><a name="zh-cn_topic_0000001117163542_p296713699"></a><a name="zh-cn_topic_0000001117163542_p296713699"></a>类型</p> 124</th> 125<th class="cellrowborder" valign="top" width="6.825938566552901%" id="mcps1.1.5.1.3"><p id="zh-cn_topic_0000001117163542_p196718315911"><a name="zh-cn_topic_0000001117163542_p196718315911"></a><a name="zh-cn_topic_0000001117163542_p196718315911"></a>必填</p> 126</th> 127<th class="cellrowborder" valign="top" width="59.76596782057533%" id="mcps1.1.5.1.4"><p id="zh-cn_topic_0000001117163542_p9967231197"><a name="zh-cn_topic_0000001117163542_p9967231197"></a><a name="zh-cn_topic_0000001117163542_p9967231197"></a>说明</p> 128</th> 129</tr> 130</thead> 131<tbody><tr id="zh-cn_topic_0000001117163542_row99671533914"><td class="cellrowborder" valign="top" width="14.451487079473427%" headers="mcps1.1.5.1.1 "><p id="zh-cn_topic_0000001117163542_p79671633910"><a name="zh-cn_topic_0000001117163542_p79671633910"></a><a name="zh-cn_topic_0000001117163542_p79671633910"></a>path</p> 132</td> 133<td class="cellrowborder" valign="top" width="18.95660653339834%" headers="mcps1.1.5.1.2 "><p id="zh-cn_topic_0000001117163542_p11967433914"><a name="zh-cn_topic_0000001117163542_p11967433914"></a><a name="zh-cn_topic_0000001117163542_p11967433914"></a>string</p> 134</td> 135<td class="cellrowborder" valign="top" width="6.825938566552901%" headers="mcps1.1.5.1.3 "><p id="zh-cn_topic_0000001117163542_p19671336916"><a name="zh-cn_topic_0000001117163542_p19671336916"></a><a name="zh-cn_topic_0000001117163542_p19671336916"></a>是</p> 136</td> 137<td class="cellrowborder" valign="top" width="59.76596782057533%" headers="mcps1.1.5.1.4 "><p id="zh-cn_topic_0000001117163542_p98628113304"><a name="zh-cn_topic_0000001117163542_p98628113304"></a><a name="zh-cn_topic_0000001117163542_p98628113304"></a>应用程序内部数据存储路径。</p> 138</td> 139</tr> 140<tr id="zh-cn_topic_0000001117163542_row128961021101812"><td class="cellrowborder" valign="top" width="14.451487079473427%" headers="mcps1.1.5.1.1 "><p id="zh-cn_topic_0000001117163542_p6897172121814"><a name="zh-cn_topic_0000001117163542_p6897172121814"></a><a name="zh-cn_topic_0000001117163542_p6897172121814"></a>callback</p> 141</td> 142<td class="cellrowborder" valign="top" width="18.95660653339834%" headers="mcps1.1.5.1.2 "><p id="zh-cn_topic_0000001117163542_p9897102181813"><a name="zh-cn_topic_0000001117163542_p9897102181813"></a><a name="zh-cn_topic_0000001117163542_p9897102181813"></a>AsyncCallback<<a href="#zh-cn_topic_0000001117163542_section12882825611">Storage</a>></p> 143</td> 144<td class="cellrowborder" valign="top" width="6.825938566552901%" headers="mcps1.1.5.1.3 "><p id="zh-cn_topic_0000001117163542_p188982219189"><a name="zh-cn_topic_0000001117163542_p188982219189"></a><a name="zh-cn_topic_0000001117163542_p188982219189"></a>是</p> 145</td> 146<td class="cellrowborder" valign="top" width="59.76596782057533%" headers="mcps1.1.5.1.4 "><p id="zh-cn_topic_0000001117163542_p989815213187"><a name="zh-cn_topic_0000001117163542_p989815213187"></a><a name="zh-cn_topic_0000001117163542_p989815213187"></a>回调函数。</p> 147</td> 148</tr> 149</tbody> 150</table> 151 152**返回值:** 153 154<a name="zh-cn_topic_0000001117163542_table16391145317913"></a> 155<table><thead align="left"><tr id="zh-cn_topic_0000001117163542_row2391145319910"><th class="cellrowborder" valign="top" width="17.01%" id="mcps1.1.3.1.1"><p id="zh-cn_topic_0000001117163542_p13911353991"><a name="zh-cn_topic_0000001117163542_p13911353991"></a><a name="zh-cn_topic_0000001117163542_p13911353991"></a>类型</p> 156</th> 157<th class="cellrowborder" valign="top" width="82.99%" id="mcps1.1.3.1.2"><p id="zh-cn_topic_0000001117163542_p193911531395"><a name="zh-cn_topic_0000001117163542_p193911531395"></a><a name="zh-cn_topic_0000001117163542_p193911531395"></a>说明</p> 158</th> 159</tr> 160</thead> 161<tbody><tr id="zh-cn_topic_0000001117163542_row1339114531391"><td class="cellrowborder" valign="top" width="17.01%" headers="mcps1.1.3.1.1 "><p id="zh-cn_topic_0000001117163542_p1777116115195"><a name="zh-cn_topic_0000001117163542_p1777116115195"></a><a name="zh-cn_topic_0000001117163542_p1777116115195"></a>void</p> 162</td> 163<td class="cellrowborder" valign="top" width="82.99%" headers="mcps1.1.3.1.2 "><p id="zh-cn_topic_0000001117163542_p1039217531898"><a name="zh-cn_topic_0000001117163542_p1039217531898"></a><a name="zh-cn_topic_0000001117163542_p1039217531898"></a>无</p> 164</td> 165</tr> 166</tbody> 167</table> 168 169**示例:** 170 171``` 172data_storage.getStorage(PATH, function(err, data) { 173 strore = data; 174}); 175``` 176 177## getStorage\(path: string\)<a name="zh-cn_topic_0000001117163542_section761705115251"></a> 178 179读取指定文件,将数据加载到Storage实例,用于数据操作。 180 181此方法为异步方法。 182 183**参数:** 184 185<a name="zh-cn_topic_0000001117163542_table206180511253"></a> 186<table><thead align="left"><tr id="zh-cn_topic_0000001117163542_row126181951152513"><th class="cellrowborder" valign="top" width="14.451487079473427%" id="mcps1.1.5.1.1"><p id="zh-cn_topic_0000001117163542_p20618155112513"><a name="zh-cn_topic_0000001117163542_p20618155112513"></a><a name="zh-cn_topic_0000001117163542_p20618155112513"></a>参数名</p> 187</th> 188<th class="cellrowborder" valign="top" width="18.95660653339834%" id="mcps1.1.5.1.2"><p id="zh-cn_topic_0000001117163542_p561885114256"><a name="zh-cn_topic_0000001117163542_p561885114256"></a><a name="zh-cn_topic_0000001117163542_p561885114256"></a>类型</p> 189</th> 190<th class="cellrowborder" valign="top" width="6.825938566552901%" id="mcps1.1.5.1.3"><p id="zh-cn_topic_0000001117163542_p561814519259"><a name="zh-cn_topic_0000001117163542_p561814519259"></a><a name="zh-cn_topic_0000001117163542_p561814519259"></a>必填</p> 191</th> 192<th class="cellrowborder" valign="top" width="59.76596782057533%" id="mcps1.1.5.1.4"><p id="zh-cn_topic_0000001117163542_p1861845120252"><a name="zh-cn_topic_0000001117163542_p1861845120252"></a><a name="zh-cn_topic_0000001117163542_p1861845120252"></a>说明</p> 193</th> 194</tr> 195</thead> 196<tbody><tr id="zh-cn_topic_0000001117163542_row6619751162515"><td class="cellrowborder" valign="top" width="14.451487079473427%" headers="mcps1.1.5.1.1 "><p id="zh-cn_topic_0000001117163542_p196192514253"><a name="zh-cn_topic_0000001117163542_p196192514253"></a><a name="zh-cn_topic_0000001117163542_p196192514253"></a>path</p> 197</td> 198<td class="cellrowborder" valign="top" width="18.95660653339834%" headers="mcps1.1.5.1.2 "><p id="zh-cn_topic_0000001117163542_p36191951162515"><a name="zh-cn_topic_0000001117163542_p36191951162515"></a><a name="zh-cn_topic_0000001117163542_p36191951162515"></a>string</p> 199</td> 200<td class="cellrowborder" valign="top" width="6.825938566552901%" headers="mcps1.1.5.1.3 "><p id="zh-cn_topic_0000001117163542_p16191051162511"><a name="zh-cn_topic_0000001117163542_p16191051162511"></a><a name="zh-cn_topic_0000001117163542_p16191051162511"></a>是</p> 201</td> 202<td class="cellrowborder" valign="top" width="59.76596782057533%" headers="mcps1.1.5.1.4 "><p id="zh-cn_topic_0000001117163542_p48655421106"><a name="zh-cn_topic_0000001117163542_p48655421106"></a><a name="zh-cn_topic_0000001117163542_p48655421106"></a>应用程序内部数据存储路径。</p> 203</td> 204</tr> 205</tbody> 206</table> 207 208**返回值:** 209 210<a name="zh-cn_topic_0000001117163542_table2619551122516"></a> 211<table><thead align="left"><tr id="zh-cn_topic_0000001117163542_row46201751152513"><th class="cellrowborder" valign="top" width="17.01%" id="mcps1.1.3.1.1"><p id="zh-cn_topic_0000001117163542_p1162075110255"><a name="zh-cn_topic_0000001117163542_p1162075110255"></a><a name="zh-cn_topic_0000001117163542_p1162075110255"></a>类型</p> 212</th> 213<th class="cellrowborder" valign="top" width="82.99%" id="mcps1.1.3.1.2"><p id="zh-cn_topic_0000001117163542_p46202512251"><a name="zh-cn_topic_0000001117163542_p46202512251"></a><a name="zh-cn_topic_0000001117163542_p46202512251"></a>说明</p> 214</th> 215</tr> 216</thead> 217<tbody><tr id="zh-cn_topic_0000001117163542_row562015514258"><td class="cellrowborder" valign="top" width="17.01%" headers="mcps1.1.3.1.1 "><p id="zh-cn_topic_0000001117163542_p146201551122516"><a name="zh-cn_topic_0000001117163542_p146201551122516"></a><a name="zh-cn_topic_0000001117163542_p146201551122516"></a>Promise<Storage></p> 218</td> 219<td class="cellrowborder" valign="top" width="82.99%" headers="mcps1.1.3.1.2 "><p id="zh-cn_topic_0000001117163542_p1062005172514"><a name="zh-cn_topic_0000001117163542_p1062005172514"></a><a name="zh-cn_topic_0000001117163542_p1062005172514"></a>Promise实例,用于异步获取结果。</p> 220</td> 221</tr> 222</tbody> 223</table> 224 225**示例:** 226 227``` 228const promise = data_storage.getStorage(PATH); 229promise.then((data) => { 230 data.clearSync(); 231 }).catch((err) => { 232}); 233``` 234 235## deleteStorageSync\(path: string\)<a name="zh-cn_topic_0000001117163542_section1396463815379"></a> 236 237从内存中移除指定文件对应的Storage单实例,并删除指定文件及其备份文件、损坏文件。删除指定文件时,应用不允许再使用该实例进行数据操作,否则会出现数据一致性问题。 238 239此方法为同步方法。 240 241**参数:** 242 243<a name="zh-cn_topic_0000001117163542_table99651538193711"></a> 244<table><thead align="left"><tr id="zh-cn_topic_0000001117163542_row1296553843712"><th class="cellrowborder" valign="top" width="14.82%" id="mcps1.1.5.1.1"><p id="zh-cn_topic_0000001117163542_p19965183833714"><a name="zh-cn_topic_0000001117163542_p19965183833714"></a><a name="zh-cn_topic_0000001117163542_p19965183833714"></a>参数名</p> 245</th> 246<th class="cellrowborder" valign="top" width="14.729999999999999%" id="mcps1.1.5.1.2"><p id="zh-cn_topic_0000001117163542_p9965153863713"><a name="zh-cn_topic_0000001117163542_p9965153863713"></a><a name="zh-cn_topic_0000001117163542_p9965153863713"></a>类型</p> 247</th> 248<th class="cellrowborder" valign="top" width="9.16%" id="mcps1.1.5.1.3"><p id="zh-cn_topic_0000001117163542_p15965133819375"><a name="zh-cn_topic_0000001117163542_p15965133819375"></a><a name="zh-cn_topic_0000001117163542_p15965133819375"></a>必填</p> 249</th> 250<th class="cellrowborder" valign="top" width="61.29%" id="mcps1.1.5.1.4"><p id="zh-cn_topic_0000001117163542_p496518383377"><a name="zh-cn_topic_0000001117163542_p496518383377"></a><a name="zh-cn_topic_0000001117163542_p496518383377"></a>说明</p> 251</th> 252</tr> 253</thead> 254<tbody><tr id="zh-cn_topic_0000001117163542_row6965238143718"><td class="cellrowborder" valign="top" width="14.82%" headers="mcps1.1.5.1.1 "><p id="zh-cn_topic_0000001117163542_p18965163816378"><a name="zh-cn_topic_0000001117163542_p18965163816378"></a><a name="zh-cn_topic_0000001117163542_p18965163816378"></a>path</p> 255</td> 256<td class="cellrowborder" valign="top" width="14.729999999999999%" headers="mcps1.1.5.1.2 "><p id="zh-cn_topic_0000001117163542_p10965193816372"><a name="zh-cn_topic_0000001117163542_p10965193816372"></a><a name="zh-cn_topic_0000001117163542_p10965193816372"></a>string</p> 257</td> 258<td class="cellrowborder" valign="top" width="9.16%" headers="mcps1.1.5.1.3 "><p id="zh-cn_topic_0000001117163542_p896623833719"><a name="zh-cn_topic_0000001117163542_p896623833719"></a><a name="zh-cn_topic_0000001117163542_p896623833719"></a>是</p> 259</td> 260<td class="cellrowborder" valign="top" width="61.29%" headers="mcps1.1.5.1.4 "><p id="zh-cn_topic_0000001117163542_p1461995119256"><a name="zh-cn_topic_0000001117163542_p1461995119256"></a><a name="zh-cn_topic_0000001117163542_p1461995119256"></a>应用程序内部数据存储路径。</p> 261</td> 262</tr> 263</tbody> 264</table> 265 266**返回值:** 267 268<a name="zh-cn_topic_0000001117163542_table13966838153711"></a> 269<table><thead align="left"><tr id="zh-cn_topic_0000001117163542_row89664383379"><th class="cellrowborder" valign="top" width="17.01%" id="mcps1.1.3.1.1"><p id="zh-cn_topic_0000001117163542_p169661638163716"><a name="zh-cn_topic_0000001117163542_p169661638163716"></a><a name="zh-cn_topic_0000001117163542_p169661638163716"></a>类型</p> 270</th> 271<th class="cellrowborder" valign="top" width="82.99%" id="mcps1.1.3.1.2"><p id="zh-cn_topic_0000001117163542_p29661138123715"><a name="zh-cn_topic_0000001117163542_p29661138123715"></a><a name="zh-cn_topic_0000001117163542_p29661138123715"></a>说明</p> 272</th> 273</tr> 274</thead> 275<tbody><tr id="zh-cn_topic_0000001117163542_row796614387378"><td class="cellrowborder" valign="top" width="17.01%" headers="mcps1.1.3.1.1 "><p id="zh-cn_topic_0000001117163542_p696653853714"><a name="zh-cn_topic_0000001117163542_p696653853714"></a><a name="zh-cn_topic_0000001117163542_p696653853714"></a>void</p> 276</td> 277<td class="cellrowborder" valign="top" width="82.99%" headers="mcps1.1.3.1.2 "><p id="zh-cn_topic_0000001117163542_p11966103843716"><a name="zh-cn_topic_0000001117163542_p11966103843716"></a><a name="zh-cn_topic_0000001117163542_p11966103843716"></a>无</p> 278</td> 279</tr> 280</tbody> 281</table> 282 283**示例:** 284 285``` 286const PATH = '/data/accounts/account_0/appdata/com.example.myapplication/database/{storage_name}'; 287data_storage.deleteStorageSync(PATH); 288``` 289 290## deleteStorage\(path: string, callback: AsyncCallback<Storage\>\)<a name="zh-cn_topic_0000001117163542_section17967123883712"></a> 291 292从内存中移除指定文件对应的Storage单实例,并删除指定文件及其备份文件、损坏文件。删除指定文件时,应用不允许再使用该实例进行数据操作,否则会出现数据一致性问题。 293 294此方法为异步方法。 295 296**参数:** 297 298<a name="zh-cn_topic_0000001117163542_table1296893843713"></a> 299<table><thead align="left"><tr id="zh-cn_topic_0000001117163542_row5968193863710"><th class="cellrowborder" valign="top" width="14.451487079473427%" id="mcps1.1.5.1.1"><p id="zh-cn_topic_0000001117163542_p99681338103714"><a name="zh-cn_topic_0000001117163542_p99681338103714"></a><a name="zh-cn_topic_0000001117163542_p99681338103714"></a>参数名</p> 300</th> 301<th class="cellrowborder" valign="top" width="18.95660653339834%" id="mcps1.1.5.1.2"><p id="zh-cn_topic_0000001117163542_p1968838123715"><a name="zh-cn_topic_0000001117163542_p1968838123715"></a><a name="zh-cn_topic_0000001117163542_p1968838123715"></a>类型</p> 302</th> 303<th class="cellrowborder" valign="top" width="6.825938566552901%" id="mcps1.1.5.1.3"><p id="zh-cn_topic_0000001117163542_p14968123803720"><a name="zh-cn_topic_0000001117163542_p14968123803720"></a><a name="zh-cn_topic_0000001117163542_p14968123803720"></a>必填</p> 304</th> 305<th class="cellrowborder" valign="top" width="59.76596782057533%" id="mcps1.1.5.1.4"><p id="zh-cn_topic_0000001117163542_p7968238143715"><a name="zh-cn_topic_0000001117163542_p7968238143715"></a><a name="zh-cn_topic_0000001117163542_p7968238143715"></a>说明</p> 306</th> 307</tr> 308</thead> 309<tbody><tr id="zh-cn_topic_0000001117163542_row129691538133719"><td class="cellrowborder" valign="top" width="14.451487079473427%" headers="mcps1.1.5.1.1 "><p id="zh-cn_topic_0000001117163542_p14969438143718"><a name="zh-cn_topic_0000001117163542_p14969438143718"></a><a name="zh-cn_topic_0000001117163542_p14969438143718"></a>path</p> 310</td> 311<td class="cellrowborder" valign="top" width="18.95660653339834%" headers="mcps1.1.5.1.2 "><p id="zh-cn_topic_0000001117163542_p9969123873716"><a name="zh-cn_topic_0000001117163542_p9969123873716"></a><a name="zh-cn_topic_0000001117163542_p9969123873716"></a>string</p> 312</td> 313<td class="cellrowborder" valign="top" width="6.825938566552901%" headers="mcps1.1.5.1.3 "><p id="zh-cn_topic_0000001117163542_p159691438173711"><a name="zh-cn_topic_0000001117163542_p159691438173711"></a><a name="zh-cn_topic_0000001117163542_p159691438173711"></a>是</p> 314</td> 315<td class="cellrowborder" valign="top" width="59.76596782057533%" headers="mcps1.1.5.1.4 "><p id="zh-cn_topic_0000001117163542_p06171654601"><a name="zh-cn_topic_0000001117163542_p06171654601"></a><a name="zh-cn_topic_0000001117163542_p06171654601"></a>应用程序内部数据存储路径。</p> 316</td> 317</tr> 318<tr id="zh-cn_topic_0000001117163542_row9969173819374"><td class="cellrowborder" valign="top" width="14.451487079473427%" headers="mcps1.1.5.1.1 "><p id="zh-cn_topic_0000001117163542_p69691238153715"><a name="zh-cn_topic_0000001117163542_p69691238153715"></a><a name="zh-cn_topic_0000001117163542_p69691238153715"></a>callback</p> 319</td> 320<td class="cellrowborder" valign="top" width="18.95660653339834%" headers="mcps1.1.5.1.2 "><p id="zh-cn_topic_0000001117163542_p149691380378"><a name="zh-cn_topic_0000001117163542_p149691380378"></a><a name="zh-cn_topic_0000001117163542_p149691380378"></a>AsyncCallback<<a href="#zh-cn_topic_0000001117163542_section12882825611">Storage</a>></p> 321</td> 322<td class="cellrowborder" valign="top" width="6.825938566552901%" headers="mcps1.1.5.1.3 "><p id="zh-cn_topic_0000001117163542_p2969103843715"><a name="zh-cn_topic_0000001117163542_p2969103843715"></a><a name="zh-cn_topic_0000001117163542_p2969103843715"></a>是</p> 323</td> 324<td class="cellrowborder" valign="top" width="59.76596782057533%" headers="mcps1.1.5.1.4 "><p id="zh-cn_topic_0000001117163542_p396915388374"><a name="zh-cn_topic_0000001117163542_p396915388374"></a><a name="zh-cn_topic_0000001117163542_p396915388374"></a>回调函数。</p> 325</td> 326</tr> 327</tbody> 328</table> 329 330**返回值:** 331 332<a name="zh-cn_topic_0000001117163542_table15970938123715"></a> 333<table><thead align="left"><tr id="zh-cn_topic_0000001117163542_row3970638173711"><th class="cellrowborder" valign="top" width="17.01%" id="mcps1.1.3.1.1"><p id="zh-cn_topic_0000001117163542_p12970183811375"><a name="zh-cn_topic_0000001117163542_p12970183811375"></a><a name="zh-cn_topic_0000001117163542_p12970183811375"></a>类型</p> 334</th> 335<th class="cellrowborder" valign="top" width="82.99%" id="mcps1.1.3.1.2"><p id="zh-cn_topic_0000001117163542_p159701938143717"><a name="zh-cn_topic_0000001117163542_p159701938143717"></a><a name="zh-cn_topic_0000001117163542_p159701938143717"></a>说明</p> 336</th> 337</tr> 338</thead> 339<tbody><tr id="zh-cn_topic_0000001117163542_row9970438123710"><td class="cellrowborder" valign="top" width="17.01%" headers="mcps1.1.3.1.1 "><p id="zh-cn_topic_0000001117163542_p139701038103712"><a name="zh-cn_topic_0000001117163542_p139701038103712"></a><a name="zh-cn_topic_0000001117163542_p139701038103712"></a>void</p> 340</td> 341<td class="cellrowborder" valign="top" width="82.99%" headers="mcps1.1.3.1.2 "><p id="zh-cn_topic_0000001117163542_p997073811371"><a name="zh-cn_topic_0000001117163542_p997073811371"></a><a name="zh-cn_topic_0000001117163542_p997073811371"></a>无</p> 342</td> 343</tr> 344</tbody> 345</table> 346 347**示例:** 348 349``` 350data_storage.deleteStorage(PATH, function(err, data) { 351}); 352``` 353 354## deleteStorage\(path: string\)<a name="zh-cn_topic_0000001117163542_section1497163823719"></a> 355 356从内存中移除指定文件对应的Storage单实例,并删除指定文件及其备份文件、损坏文件。删除指定文件时,应用不允许再使用该实例进行数据操作,否则会出现数据一致性问题。 357 358此方法为异步方法。 359 360**参数:** 361 362<a name="zh-cn_topic_0000001117163542_table597293815378"></a> 363<table><thead align="left"><tr id="zh-cn_topic_0000001117163542_row29721938203716"><th class="cellrowborder" valign="top" width="14.451487079473427%" id="mcps1.1.5.1.1"><p id="zh-cn_topic_0000001117163542_p19972173883714"><a name="zh-cn_topic_0000001117163542_p19972173883714"></a><a name="zh-cn_topic_0000001117163542_p19972173883714"></a>参数名</p> 364</th> 365<th class="cellrowborder" valign="top" width="18.95660653339834%" id="mcps1.1.5.1.2"><p id="zh-cn_topic_0000001117163542_p49721938103718"><a name="zh-cn_topic_0000001117163542_p49721938103718"></a><a name="zh-cn_topic_0000001117163542_p49721938103718"></a>类型</p> 366</th> 367<th class="cellrowborder" valign="top" width="6.825938566552901%" id="mcps1.1.5.1.3"><p id="zh-cn_topic_0000001117163542_p17972113863711"><a name="zh-cn_topic_0000001117163542_p17972113863711"></a><a name="zh-cn_topic_0000001117163542_p17972113863711"></a>必填</p> 368</th> 369<th class="cellrowborder" valign="top" width="59.76596782057533%" id="mcps1.1.5.1.4"><p id="zh-cn_topic_0000001117163542_p15972838123714"><a name="zh-cn_topic_0000001117163542_p15972838123714"></a><a name="zh-cn_topic_0000001117163542_p15972838123714"></a>说明</p> 370</th> 371</tr> 372</thead> 373<tbody><tr id="zh-cn_topic_0000001117163542_row1972163818374"><td class="cellrowborder" valign="top" width="14.451487079473427%" headers="mcps1.1.5.1.1 "><p id="zh-cn_topic_0000001117163542_p597373833717"><a name="zh-cn_topic_0000001117163542_p597373833717"></a><a name="zh-cn_topic_0000001117163542_p597373833717"></a>path</p> 374</td> 375<td class="cellrowborder" valign="top" width="18.95660653339834%" headers="mcps1.1.5.1.2 "><p id="zh-cn_topic_0000001117163542_p11973173814378"><a name="zh-cn_topic_0000001117163542_p11973173814378"></a><a name="zh-cn_topic_0000001117163542_p11973173814378"></a>string</p> 376</td> 377<td class="cellrowborder" valign="top" width="6.825938566552901%" headers="mcps1.1.5.1.3 "><p id="zh-cn_topic_0000001117163542_p209732388379"><a name="zh-cn_topic_0000001117163542_p209732388379"></a><a name="zh-cn_topic_0000001117163542_p209732388379"></a>是</p> 378</td> 379<td class="cellrowborder" valign="top" width="59.76596782057533%" headers="mcps1.1.5.1.4 "><p id="zh-cn_topic_0000001117163542_p20324115919012"><a name="zh-cn_topic_0000001117163542_p20324115919012"></a><a name="zh-cn_topic_0000001117163542_p20324115919012"></a>应用程序内部数据存储路径。</p> 380</td> 381</tr> 382</tbody> 383</table> 384 385**返回值:** 386 387<a name="zh-cn_topic_0000001117163542_table5973738153710"></a> 388<table><thead align="left"><tr id="zh-cn_topic_0000001117163542_row17973238123713"><th class="cellrowborder" valign="top" width="17.01%" id="mcps1.1.3.1.1"><p id="zh-cn_topic_0000001117163542_p17973538183719"><a name="zh-cn_topic_0000001117163542_p17973538183719"></a><a name="zh-cn_topic_0000001117163542_p17973538183719"></a>类型</p> 389</th> 390<th class="cellrowborder" valign="top" width="82.99%" id="mcps1.1.3.1.2"><p id="zh-cn_topic_0000001117163542_p109731385374"><a name="zh-cn_topic_0000001117163542_p109731385374"></a><a name="zh-cn_topic_0000001117163542_p109731385374"></a>说明</p> 391</th> 392</tr> 393</thead> 394<tbody><tr id="zh-cn_topic_0000001117163542_row89731838173711"><td class="cellrowborder" valign="top" width="17.01%" headers="mcps1.1.3.1.1 "><p id="zh-cn_topic_0000001117163542_p34467362719"><a name="zh-cn_topic_0000001117163542_p34467362719"></a><a name="zh-cn_topic_0000001117163542_p34467362719"></a>Promise<void></p> 395</td> 396<td class="cellrowborder" valign="top" width="82.99%" headers="mcps1.1.3.1.2 "><p id="zh-cn_topic_0000001117163542_p15446536474"><a name="zh-cn_topic_0000001117163542_p15446536474"></a><a name="zh-cn_topic_0000001117163542_p15446536474"></a>Promise实例,用于异步获取结果。</p> 397</td> 398</tr> 399</tbody> 400</table> 401 402**示例:** 403 404``` 405const promise = data_storage.deleteStorage(PATH); 406promise.then((data) => { 407 }).catch((err) => { 408}); 409``` 410 411## removeStorageFromCacheSync\(path: string\)<a name="zh-cn_topic_0000001117163542_section1212418572425"></a> 412 413从内存中移除指定文件对应的Storage单实例。移除Storage单实例时,应用不允许再使用该实例进行数据操作,否则会出现数据一致性问题。 414 415此方法为同步方法。 416 417**参数:** 418 419<a name="zh-cn_topic_0000001117163542_table121245571424"></a> 420<table><thead align="left"><tr id="zh-cn_topic_0000001117163542_row61241257164218"><th class="cellrowborder" valign="top" width="14.82%" id="mcps1.1.5.1.1"><p id="zh-cn_topic_0000001117163542_p13125165744216"><a name="zh-cn_topic_0000001117163542_p13125165744216"></a><a name="zh-cn_topic_0000001117163542_p13125165744216"></a>参数名</p> 421</th> 422<th class="cellrowborder" valign="top" width="14.729999999999999%" id="mcps1.1.5.1.2"><p id="zh-cn_topic_0000001117163542_p141259575429"><a name="zh-cn_topic_0000001117163542_p141259575429"></a><a name="zh-cn_topic_0000001117163542_p141259575429"></a>类型</p> 423</th> 424<th class="cellrowborder" valign="top" width="9.16%" id="mcps1.1.5.1.3"><p id="zh-cn_topic_0000001117163542_p1312515724213"><a name="zh-cn_topic_0000001117163542_p1312515724213"></a><a name="zh-cn_topic_0000001117163542_p1312515724213"></a>必填</p> 425</th> 426<th class="cellrowborder" valign="top" width="61.29%" id="mcps1.1.5.1.4"><p id="zh-cn_topic_0000001117163542_p6125157124212"><a name="zh-cn_topic_0000001117163542_p6125157124212"></a><a name="zh-cn_topic_0000001117163542_p6125157124212"></a>说明</p> 427</th> 428</tr> 429</thead> 430<tbody><tr id="zh-cn_topic_0000001117163542_row1112595715421"><td class="cellrowborder" valign="top" width="14.82%" headers="mcps1.1.5.1.1 "><p id="zh-cn_topic_0000001117163542_p1712610572429"><a name="zh-cn_topic_0000001117163542_p1712610572429"></a><a name="zh-cn_topic_0000001117163542_p1712610572429"></a>path</p> 431</td> 432<td class="cellrowborder" valign="top" width="14.729999999999999%" headers="mcps1.1.5.1.2 "><p id="zh-cn_topic_0000001117163542_p5126457164217"><a name="zh-cn_topic_0000001117163542_p5126457164217"></a><a name="zh-cn_topic_0000001117163542_p5126457164217"></a>string</p> 433</td> 434<td class="cellrowborder" valign="top" width="9.16%" headers="mcps1.1.5.1.3 "><p id="zh-cn_topic_0000001117163542_p19126457134212"><a name="zh-cn_topic_0000001117163542_p19126457134212"></a><a name="zh-cn_topic_0000001117163542_p19126457134212"></a>是</p> 435</td> 436<td class="cellrowborder" valign="top" width="61.29%" headers="mcps1.1.5.1.4 "><p id="zh-cn_topic_0000001117163542_p2188654116"><a name="zh-cn_topic_0000001117163542_p2188654116"></a><a name="zh-cn_topic_0000001117163542_p2188654116"></a>应用程序内部数据存储路径。</p> 437</td> 438</tr> 439</tbody> 440</table> 441 442**返回值:** 443 444<a name="zh-cn_topic_0000001117163542_table1412655711424"></a> 445<table><thead align="left"><tr id="zh-cn_topic_0000001117163542_row4126257104216"><th class="cellrowborder" valign="top" width="17.01%" id="mcps1.1.3.1.1"><p id="zh-cn_topic_0000001117163542_p10126757144216"><a name="zh-cn_topic_0000001117163542_p10126757144216"></a><a name="zh-cn_topic_0000001117163542_p10126757144216"></a>类型</p> 446</th> 447<th class="cellrowborder" valign="top" width="82.99%" id="mcps1.1.3.1.2"><p id="zh-cn_topic_0000001117163542_p3127195720429"><a name="zh-cn_topic_0000001117163542_p3127195720429"></a><a name="zh-cn_topic_0000001117163542_p3127195720429"></a>说明</p> 448</th> 449</tr> 450</thead> 451<tbody><tr id="zh-cn_topic_0000001117163542_row312795754210"><td class="cellrowborder" valign="top" width="17.01%" headers="mcps1.1.3.1.1 "><p id="zh-cn_topic_0000001117163542_p15127105794220"><a name="zh-cn_topic_0000001117163542_p15127105794220"></a><a name="zh-cn_topic_0000001117163542_p15127105794220"></a>void</p> 452</td> 453<td class="cellrowborder" valign="top" width="82.99%" headers="mcps1.1.3.1.2 "><p id="zh-cn_topic_0000001117163542_p11127857164219"><a name="zh-cn_topic_0000001117163542_p11127857164219"></a><a name="zh-cn_topic_0000001117163542_p11127857164219"></a>无</p> 454</td> 455</tr> 456</tbody> 457</table> 458 459**示例:** 460 461``` 462const PATH = '/data/accounts/account_0/appdata/com.example.myapplication/database/{storage_name}'; 463data_storage.removeStorageFromCacheSync(PATH); 464``` 465 466## removeStorageFromCache\(path: string, callback: AsyncCallback<Storage\>\)<a name="zh-cn_topic_0000001117163542_section141288570429"></a> 467 468从内存中移除指定文件对应的Storage单实例。移除Storage单实例时,应用不允许再使用该实例进行数据操作,否则会出现数据一致性问题。 469 470此方法为异步方法。 471 472**参数:** 473 474<a name="zh-cn_topic_0000001117163542_table12128115713423"></a> 475<table><thead align="left"><tr id="zh-cn_topic_0000001117163542_row131291857124212"><th class="cellrowborder" valign="top" width="14.451487079473427%" id="mcps1.1.5.1.1"><p id="zh-cn_topic_0000001117163542_p181291157174220"><a name="zh-cn_topic_0000001117163542_p181291157174220"></a><a name="zh-cn_topic_0000001117163542_p181291157174220"></a>参数名</p> 476</th> 477<th class="cellrowborder" valign="top" width="18.95660653339834%" id="mcps1.1.5.1.2"><p id="zh-cn_topic_0000001117163542_p20129205715426"><a name="zh-cn_topic_0000001117163542_p20129205715426"></a><a name="zh-cn_topic_0000001117163542_p20129205715426"></a>类型</p> 478</th> 479<th class="cellrowborder" valign="top" width="6.825938566552901%" id="mcps1.1.5.1.3"><p id="zh-cn_topic_0000001117163542_p21294574428"><a name="zh-cn_topic_0000001117163542_p21294574428"></a><a name="zh-cn_topic_0000001117163542_p21294574428"></a>必填</p> 480</th> 481<th class="cellrowborder" valign="top" width="59.76596782057533%" id="mcps1.1.5.1.4"><p id="zh-cn_topic_0000001117163542_p512965716425"><a name="zh-cn_topic_0000001117163542_p512965716425"></a><a name="zh-cn_topic_0000001117163542_p512965716425"></a>说明</p> 482</th> 483</tr> 484</thead> 485<tbody><tr id="zh-cn_topic_0000001117163542_row21299574423"><td class="cellrowborder" valign="top" width="14.451487079473427%" headers="mcps1.1.5.1.1 "><p id="zh-cn_topic_0000001117163542_p17129105714421"><a name="zh-cn_topic_0000001117163542_p17129105714421"></a><a name="zh-cn_topic_0000001117163542_p17129105714421"></a>path</p> 486</td> 487<td class="cellrowborder" valign="top" width="18.95660653339834%" headers="mcps1.1.5.1.2 "><p id="zh-cn_topic_0000001117163542_p7129185794217"><a name="zh-cn_topic_0000001117163542_p7129185794217"></a><a name="zh-cn_topic_0000001117163542_p7129185794217"></a>string</p> 488</td> 489<td class="cellrowborder" valign="top" width="6.825938566552901%" headers="mcps1.1.5.1.3 "><p id="zh-cn_topic_0000001117163542_p813075717426"><a name="zh-cn_topic_0000001117163542_p813075717426"></a><a name="zh-cn_topic_0000001117163542_p813075717426"></a>是</p> 490</td> 491<td class="cellrowborder" valign="top" width="59.76596782057533%" headers="mcps1.1.5.1.4 "><p id="zh-cn_topic_0000001117163542_p3442141014113"><a name="zh-cn_topic_0000001117163542_p3442141014113"></a><a name="zh-cn_topic_0000001117163542_p3442141014113"></a>应用程序内部数据存储路径。</p> 492</td> 493</tr> 494<tr id="zh-cn_topic_0000001117163542_row1813015717423"><td class="cellrowborder" valign="top" width="14.451487079473427%" headers="mcps1.1.5.1.1 "><p id="zh-cn_topic_0000001117163542_p813085711421"><a name="zh-cn_topic_0000001117163542_p813085711421"></a><a name="zh-cn_topic_0000001117163542_p813085711421"></a>callback</p> 495</td> 496<td class="cellrowborder" valign="top" width="18.95660653339834%" headers="mcps1.1.5.1.2 "><p id="zh-cn_topic_0000001117163542_p013085719427"><a name="zh-cn_topic_0000001117163542_p013085719427"></a><a name="zh-cn_topic_0000001117163542_p013085719427"></a>AsyncCallback<<a href="#zh-cn_topic_0000001117163542_section12882825611">Storage</a>></p> 497</td> 498<td class="cellrowborder" valign="top" width="6.825938566552901%" headers="mcps1.1.5.1.3 "><p id="zh-cn_topic_0000001117163542_p181301457184219"><a name="zh-cn_topic_0000001117163542_p181301457184219"></a><a name="zh-cn_topic_0000001117163542_p181301457184219"></a>是</p> 499</td> 500<td class="cellrowborder" valign="top" width="59.76596782057533%" headers="mcps1.1.5.1.4 "><p id="zh-cn_topic_0000001117163542_p191301575425"><a name="zh-cn_topic_0000001117163542_p191301575425"></a><a name="zh-cn_topic_0000001117163542_p191301575425"></a>回调函数。</p> 501</td> 502</tr> 503</tbody> 504</table> 505 506**返回值:** 507 508<a name="zh-cn_topic_0000001117163542_table16130857134217"></a> 509<table><thead align="left"><tr id="zh-cn_topic_0000001117163542_row1313118572427"><th class="cellrowborder" valign="top" width="17.01%" id="mcps1.1.3.1.1"><p id="zh-cn_topic_0000001117163542_p14131145715426"><a name="zh-cn_topic_0000001117163542_p14131145715426"></a><a name="zh-cn_topic_0000001117163542_p14131145715426"></a>类型</p> 510</th> 511<th class="cellrowborder" valign="top" width="82.99%" id="mcps1.1.3.1.2"><p id="zh-cn_topic_0000001117163542_p51311957184213"><a name="zh-cn_topic_0000001117163542_p51311957184213"></a><a name="zh-cn_topic_0000001117163542_p51311957184213"></a>说明</p> 512</th> 513</tr> 514</thead> 515<tbody><tr id="zh-cn_topic_0000001117163542_row5131185717420"><td class="cellrowborder" valign="top" width="17.01%" headers="mcps1.1.3.1.1 "><p id="zh-cn_topic_0000001117163542_p111311557154213"><a name="zh-cn_topic_0000001117163542_p111311557154213"></a><a name="zh-cn_topic_0000001117163542_p111311557154213"></a>void</p> 516</td> 517<td class="cellrowborder" valign="top" width="82.99%" headers="mcps1.1.3.1.2 "><p id="zh-cn_topic_0000001117163542_p3131857174214"><a name="zh-cn_topic_0000001117163542_p3131857174214"></a><a name="zh-cn_topic_0000001117163542_p3131857174214"></a>无</p> 518</td> 519</tr> 520</tbody> 521</table> 522 523**示例:** 524 525``` 526data_storage.removeStorageFromCache(PATH, function(err, data) { 527}); 528``` 529 530## removeStorageFromCache\(path: string\)<a name="zh-cn_topic_0000001117163542_section1813245718422"></a> 531 532从内存中移除指定文件对应的Storage单实例。移除Storage单实例时,应用不允许再使用该实例进行数据操作,否则会出现数据一致性问题。 533 534此方法为异步方法。 535 536**参数:** 537 538<a name="zh-cn_topic_0000001117163542_table2133125713429"></a> 539<table><thead align="left"><tr id="zh-cn_topic_0000001117163542_row9133857194218"><th class="cellrowborder" valign="top" width="14.451487079473427%" id="mcps1.1.5.1.1"><p id="zh-cn_topic_0000001117163542_p813355716423"><a name="zh-cn_topic_0000001117163542_p813355716423"></a><a name="zh-cn_topic_0000001117163542_p813355716423"></a>参数名</p> 540</th> 541<th class="cellrowborder" valign="top" width="18.95660653339834%" id="mcps1.1.5.1.2"><p id="zh-cn_topic_0000001117163542_p213495712420"><a name="zh-cn_topic_0000001117163542_p213495712420"></a><a name="zh-cn_topic_0000001117163542_p213495712420"></a>类型</p> 542</th> 543<th class="cellrowborder" valign="top" width="6.825938566552901%" id="mcps1.1.5.1.3"><p id="zh-cn_topic_0000001117163542_p713465724210"><a name="zh-cn_topic_0000001117163542_p713465724210"></a><a name="zh-cn_topic_0000001117163542_p713465724210"></a>必填</p> 544</th> 545<th class="cellrowborder" valign="top" width="59.76596782057533%" id="mcps1.1.5.1.4"><p id="zh-cn_topic_0000001117163542_p413425734218"><a name="zh-cn_topic_0000001117163542_p413425734218"></a><a name="zh-cn_topic_0000001117163542_p413425734218"></a>说明</p> 546</th> 547</tr> 548</thead> 549<tbody><tr id="zh-cn_topic_0000001117163542_row0134105716421"><td class="cellrowborder" valign="top" width="14.451487079473427%" headers="mcps1.1.5.1.1 "><p id="zh-cn_topic_0000001117163542_p14134135744212"><a name="zh-cn_topic_0000001117163542_p14134135744212"></a><a name="zh-cn_topic_0000001117163542_p14134135744212"></a>path</p> 550</td> 551<td class="cellrowborder" valign="top" width="18.95660653339834%" headers="mcps1.1.5.1.2 "><p id="zh-cn_topic_0000001117163542_p613417578427"><a name="zh-cn_topic_0000001117163542_p613417578427"></a><a name="zh-cn_topic_0000001117163542_p613417578427"></a>string</p> 552</td> 553<td class="cellrowborder" valign="top" width="6.825938566552901%" headers="mcps1.1.5.1.3 "><p id="zh-cn_topic_0000001117163542_p313555724217"><a name="zh-cn_topic_0000001117163542_p313555724217"></a><a name="zh-cn_topic_0000001117163542_p313555724217"></a>是</p> 554</td> 555<td class="cellrowborder" valign="top" width="59.76596782057533%" headers="mcps1.1.5.1.4 "><p id="zh-cn_topic_0000001117163542_p4728181510119"><a name="zh-cn_topic_0000001117163542_p4728181510119"></a><a name="zh-cn_topic_0000001117163542_p4728181510119"></a>应用程序内部数据存储路径。</p> 556</td> 557</tr> 558</tbody> 559</table> 560 561**返回值:** 562 563<a name="zh-cn_topic_0000001117163542_table513585718424"></a> 564<table><thead align="left"><tr id="zh-cn_topic_0000001117163542_row191352576429"><th class="cellrowborder" valign="top" width="17.01%" id="mcps1.1.3.1.1"><p id="zh-cn_topic_0000001117163542_p51351257104220"><a name="zh-cn_topic_0000001117163542_p51351257104220"></a><a name="zh-cn_topic_0000001117163542_p51351257104220"></a>类型</p> 565</th> 566<th class="cellrowborder" valign="top" width="82.99%" id="mcps1.1.3.1.2"><p id="zh-cn_topic_0000001117163542_p113611571421"><a name="zh-cn_topic_0000001117163542_p113611571421"></a><a name="zh-cn_topic_0000001117163542_p113611571421"></a>说明</p> 567</th> 568</tr> 569</thead> 570<tbody><tr id="zh-cn_topic_0000001117163542_row0136165744213"><td class="cellrowborder" valign="top" width="17.01%" headers="mcps1.1.3.1.1 "><p id="zh-cn_topic_0000001117163542_p159416454718"><a name="zh-cn_topic_0000001117163542_p159416454718"></a><a name="zh-cn_topic_0000001117163542_p159416454718"></a>Promise<void></p> 571</td> 572<td class="cellrowborder" valign="top" width="82.99%" headers="mcps1.1.3.1.2 "><p id="zh-cn_topic_0000001117163542_p13941645472"><a name="zh-cn_topic_0000001117163542_p13941645472"></a><a name="zh-cn_topic_0000001117163542_p13941645472"></a>Promise实例,用于异步获取结果。</p> 573</td> 574</tr> 575</tbody> 576</table> 577 578**示例:** 579 580``` 581const promise = data_storage.removeStorageFromCache(PATH); 582promise.then((data) => { 583 }).catch((err) => { 584}); 585``` 586 587## 附录<a name="zh-cn_topic_0000001117163542_section1933416317165"></a> 588 589## Storage<a name="zh-cn_topic_0000001117163542_section12882825611"></a> 590 591提供获取和修改存储数据的接口。 592 593## 方法<a name="zh-cn_topic_0000001117163542_section1442928184214"></a> 594 595## getSync\(key: string, defValue: ValueType\)<a name="zh-cn_topic_0000001117163542_section175783467507"></a> 596 597获取键对应的值,如果值为null或者非默认值类型,返默认数据 598 599此方法为同步方法。 600 601**参数:** 602 603<a name="zh-cn_topic_0000001117163542_table20579646175015"></a> 604<table><thead align="left"><tr id="zh-cn_topic_0000001117163542_row5579164695016"><th class="cellrowborder" valign="top" width="14.82%" id="mcps1.1.5.1.1"><p id="zh-cn_topic_0000001117163542_p7579174612503"><a name="zh-cn_topic_0000001117163542_p7579174612503"></a><a name="zh-cn_topic_0000001117163542_p7579174612503"></a>参数名</p> 605</th> 606<th class="cellrowborder" valign="top" width="14.729999999999999%" id="mcps1.1.5.1.2"><p id="zh-cn_topic_0000001117163542_p6579164685015"><a name="zh-cn_topic_0000001117163542_p6579164685015"></a><a name="zh-cn_topic_0000001117163542_p6579164685015"></a>类型</p> 607</th> 608<th class="cellrowborder" valign="top" width="9.16%" id="mcps1.1.5.1.3"><p id="zh-cn_topic_0000001117163542_p7580144625010"><a name="zh-cn_topic_0000001117163542_p7580144625010"></a><a name="zh-cn_topic_0000001117163542_p7580144625010"></a>必填</p> 609</th> 610<th class="cellrowborder" valign="top" width="61.29%" id="mcps1.1.5.1.4"><p id="zh-cn_topic_0000001117163542_p6580446195018"><a name="zh-cn_topic_0000001117163542_p6580446195018"></a><a name="zh-cn_topic_0000001117163542_p6580446195018"></a>说明</p> 611</th> 612</tr> 613</thead> 614<tbody><tr id="zh-cn_topic_0000001117163542_row958034616501"><td class="cellrowborder" valign="top" width="14.82%" headers="mcps1.1.5.1.1 "><p id="zh-cn_topic_0000001117163542_p2580144610505"><a name="zh-cn_topic_0000001117163542_p2580144610505"></a><a name="zh-cn_topic_0000001117163542_p2580144610505"></a>key</p> 615</td> 616<td class="cellrowborder" valign="top" width="14.729999999999999%" headers="mcps1.1.5.1.2 "><p id="zh-cn_topic_0000001117163542_p175802469504"><a name="zh-cn_topic_0000001117163542_p175802469504"></a><a name="zh-cn_topic_0000001117163542_p175802469504"></a>string</p> 617</td> 618<td class="cellrowborder" valign="top" width="9.16%" headers="mcps1.1.5.1.3 "><p id="zh-cn_topic_0000001117163542_p11580124614504"><a name="zh-cn_topic_0000001117163542_p11580124614504"></a><a name="zh-cn_topic_0000001117163542_p11580124614504"></a>是</p> 619</td> 620<td class="cellrowborder" valign="top" width="61.29%" headers="mcps1.1.5.1.4 "><p id="zh-cn_topic_0000001117163542_p155801846185019"><a name="zh-cn_topic_0000001117163542_p155801846185019"></a><a name="zh-cn_topic_0000001117163542_p155801846185019"></a>要获取的存储key名称。它不能为空。</p> 621</td> 622</tr> 623<tr id="zh-cn_topic_0000001117163542_row0459124213526"><td class="cellrowborder" valign="top" width="14.82%" headers="mcps1.1.5.1.1 "><p id="zh-cn_topic_0000001117163542_p14460114212525"><a name="zh-cn_topic_0000001117163542_p14460114212525"></a><a name="zh-cn_topic_0000001117163542_p14460114212525"></a>defValue</p> 624</td> 625<td class="cellrowborder" valign="top" width="14.729999999999999%" headers="mcps1.1.5.1.2 "><p id="zh-cn_topic_0000001117163542_p8460114255218"><a name="zh-cn_topic_0000001117163542_p8460114255218"></a><a name="zh-cn_topic_0000001117163542_p8460114255218"></a>ValueType</p> 626</td> 627<td class="cellrowborder" valign="top" width="9.16%" headers="mcps1.1.5.1.3 "><p id="zh-cn_topic_0000001117163542_p24601842125212"><a name="zh-cn_topic_0000001117163542_p24601842125212"></a><a name="zh-cn_topic_0000001117163542_p24601842125212"></a>是</p> 628</td> 629<td class="cellrowborder" valign="top" width="61.29%" headers="mcps1.1.5.1.4 "><p id="zh-cn_topic_0000001117163542_p1246094210525"><a name="zh-cn_topic_0000001117163542_p1246094210525"></a><a name="zh-cn_topic_0000001117163542_p1246094210525"></a>给定key的存储不存在,则要返回的默认值。支持number 、 string 、boolean。</p> 630</td> 631</tr> 632</tbody> 633</table> 634 635**返回值:** 636 637<a name="zh-cn_topic_0000001117163542_table6580194685018"></a> 638<table><thead align="left"><tr id="zh-cn_topic_0000001117163542_row165817461506"><th class="cellrowborder" valign="top" width="17.01%" id="mcps1.1.3.1.1"><p id="zh-cn_topic_0000001117163542_p6581124635014"><a name="zh-cn_topic_0000001117163542_p6581124635014"></a><a name="zh-cn_topic_0000001117163542_p6581124635014"></a>类型</p> 639</th> 640<th class="cellrowborder" valign="top" width="82.99%" id="mcps1.1.3.1.2"><p id="zh-cn_topic_0000001117163542_p155812466505"><a name="zh-cn_topic_0000001117163542_p155812466505"></a><a name="zh-cn_topic_0000001117163542_p155812466505"></a>说明</p> 641</th> 642</tr> 643</thead> 644<tbody><tr id="zh-cn_topic_0000001117163542_row158144625016"><td class="cellrowborder" valign="top" width="17.01%" headers="mcps1.1.3.1.1 "><p id="zh-cn_topic_0000001117163542_p1458174605020"><a name="zh-cn_topic_0000001117163542_p1458174605020"></a><a name="zh-cn_topic_0000001117163542_p1458174605020"></a>ValueType</p> 645</td> 646<td class="cellrowborder" valign="top" width="82.99%" headers="mcps1.1.3.1.2 "><p id="zh-cn_topic_0000001117163542_p9581174695017"><a name="zh-cn_topic_0000001117163542_p9581174695017"></a><a name="zh-cn_topic_0000001117163542_p9581174695017"></a>键对应的值,如果值为null或者非默认值类型,返默认数据</p> 647</td> 648</tr> 649</tbody> 650</table> 651 652**示例:** 653 654``` 655let ret = store.getSync(key, ‘defValue’); 656``` 657 658## get\(key: string, defValue: ValueType, callback: AsyncCallback<ValueType\>\)<a name="zh-cn_topic_0000001117163542_section858234618501"></a> 659 660获取键对应的值,如果值为null或者非默认值类型,返默认数据。 661 662此方法为异步方法。 663 664**参数:** 665 666<a name="zh-cn_topic_0000001117163542_table16582546105019"></a> 667<table><thead align="left"><tr id="zh-cn_topic_0000001117163542_row35829466507"><th class="cellrowborder" valign="top" width="14.451487079473427%" id="mcps1.1.5.1.1"><p id="zh-cn_topic_0000001117163542_p1758324675012"><a name="zh-cn_topic_0000001117163542_p1758324675012"></a><a name="zh-cn_topic_0000001117163542_p1758324675012"></a>参数名</p> 668</th> 669<th class="cellrowborder" valign="top" width="18.95660653339834%" id="mcps1.1.5.1.2"><p id="zh-cn_topic_0000001117163542_p05833469507"><a name="zh-cn_topic_0000001117163542_p05833469507"></a><a name="zh-cn_topic_0000001117163542_p05833469507"></a>类型</p> 670</th> 671<th class="cellrowborder" valign="top" width="6.825938566552901%" id="mcps1.1.5.1.3"><p id="zh-cn_topic_0000001117163542_p558344615503"><a name="zh-cn_topic_0000001117163542_p558344615503"></a><a name="zh-cn_topic_0000001117163542_p558344615503"></a>必填</p> 672</th> 673<th class="cellrowborder" valign="top" width="59.76596782057533%" id="mcps1.1.5.1.4"><p id="zh-cn_topic_0000001117163542_p1958314614504"><a name="zh-cn_topic_0000001117163542_p1958314614504"></a><a name="zh-cn_topic_0000001117163542_p1958314614504"></a>说明</p> 674</th> 675</tr> 676</thead> 677<tbody><tr id="zh-cn_topic_0000001117163542_row95831446165019"><td class="cellrowborder" valign="top" width="14.451487079473427%" headers="mcps1.1.5.1.1 "><p id="zh-cn_topic_0000001117163542_p1958354695012"><a name="zh-cn_topic_0000001117163542_p1958354695012"></a><a name="zh-cn_topic_0000001117163542_p1958354695012"></a>key</p> 678</td> 679<td class="cellrowborder" valign="top" width="18.95660653339834%" headers="mcps1.1.5.1.2 "><p id="zh-cn_topic_0000001117163542_p2583174615017"><a name="zh-cn_topic_0000001117163542_p2583174615017"></a><a name="zh-cn_topic_0000001117163542_p2583174615017"></a>string</p> 680</td> 681<td class="cellrowborder" valign="top" width="6.825938566552901%" headers="mcps1.1.5.1.3 "><p id="zh-cn_topic_0000001117163542_p758314617509"><a name="zh-cn_topic_0000001117163542_p758314617509"></a><a name="zh-cn_topic_0000001117163542_p758314617509"></a>是</p> 682</td> 683<td class="cellrowborder" valign="top" width="59.76596782057533%" headers="mcps1.1.5.1.4 "><p id="zh-cn_topic_0000001117163542_p8583846195019"><a name="zh-cn_topic_0000001117163542_p8583846195019"></a><a name="zh-cn_topic_0000001117163542_p8583846195019"></a>要获取的存储key名称。它不能为空。</p> 684</td> 685</tr> 686<tr id="zh-cn_topic_0000001117163542_row178702311721"><td class="cellrowborder" valign="top" width="14.451487079473427%" headers="mcps1.1.5.1.1 "><p id="zh-cn_topic_0000001117163542_p118713316216"><a name="zh-cn_topic_0000001117163542_p118713316216"></a><a name="zh-cn_topic_0000001117163542_p118713316216"></a>defValue</p> 687</td> 688<td class="cellrowborder" valign="top" width="18.95660653339834%" headers="mcps1.1.5.1.2 "><p id="zh-cn_topic_0000001117163542_p8871133118215"><a name="zh-cn_topic_0000001117163542_p8871133118215"></a><a name="zh-cn_topic_0000001117163542_p8871133118215"></a>ValueType</p> 689</td> 690<td class="cellrowborder" valign="top" width="6.825938566552901%" headers="mcps1.1.5.1.3 "><p id="zh-cn_topic_0000001117163542_p1387173113211"><a name="zh-cn_topic_0000001117163542_p1387173113211"></a><a name="zh-cn_topic_0000001117163542_p1387173113211"></a>是</p> 691</td> 692<td class="cellrowborder" valign="top" width="59.76596782057533%" headers="mcps1.1.5.1.4 "><p id="zh-cn_topic_0000001117163542_p6871153116215"><a name="zh-cn_topic_0000001117163542_p6871153116215"></a><a name="zh-cn_topic_0000001117163542_p6871153116215"></a>默认返回值。支持number 、 string 、boolean。</p> 693</td> 694</tr> 695<tr id="zh-cn_topic_0000001117163542_row13583144610506"><td class="cellrowborder" valign="top" width="14.451487079473427%" headers="mcps1.1.5.1.1 "><p id="zh-cn_topic_0000001117163542_p658384675012"><a name="zh-cn_topic_0000001117163542_p658384675012"></a><a name="zh-cn_topic_0000001117163542_p658384675012"></a>callback</p> 696</td> 697<td class="cellrowborder" valign="top" width="18.95660653339834%" headers="mcps1.1.5.1.2 "><p id="zh-cn_topic_0000001117163542_p18583144605020"><a name="zh-cn_topic_0000001117163542_p18583144605020"></a><a name="zh-cn_topic_0000001117163542_p18583144605020"></a>AsyncCallback<ValueType></p> 698</td> 699<td class="cellrowborder" valign="top" width="6.825938566552901%" headers="mcps1.1.5.1.3 "><p id="zh-cn_topic_0000001117163542_p17583104665016"><a name="zh-cn_topic_0000001117163542_p17583104665016"></a><a name="zh-cn_topic_0000001117163542_p17583104665016"></a>是</p> 700</td> 701<td class="cellrowborder" valign="top" width="59.76596782057533%" headers="mcps1.1.5.1.4 "><p id="zh-cn_topic_0000001117163542_p758334625010"><a name="zh-cn_topic_0000001117163542_p758334625010"></a><a name="zh-cn_topic_0000001117163542_p758334625010"></a>回调函数。</p> 702</td> 703</tr> 704</tbody> 705</table> 706 707**返回值:** 708 709<a name="zh-cn_topic_0000001117163542_table19584154619506"></a> 710<table><thead align="left"><tr id="zh-cn_topic_0000001117163542_row3584546205017"><th class="cellrowborder" valign="top" width="17.01%" id="mcps1.1.3.1.1"><p id="zh-cn_topic_0000001117163542_p2584546135015"><a name="zh-cn_topic_0000001117163542_p2584546135015"></a><a name="zh-cn_topic_0000001117163542_p2584546135015"></a>类型</p> 711</th> 712<th class="cellrowborder" valign="top" width="82.99%" id="mcps1.1.3.1.2"><p id="zh-cn_topic_0000001117163542_p7584164665013"><a name="zh-cn_topic_0000001117163542_p7584164665013"></a><a name="zh-cn_topic_0000001117163542_p7584164665013"></a>说明</p> 713</th> 714</tr> 715</thead> 716<tbody><tr id="zh-cn_topic_0000001117163542_row35847461505"><td class="cellrowborder" valign="top" width="17.01%" headers="mcps1.1.3.1.1 "><p id="zh-cn_topic_0000001117163542_p1258410462501"><a name="zh-cn_topic_0000001117163542_p1258410462501"></a><a name="zh-cn_topic_0000001117163542_p1258410462501"></a>void</p> 717</td> 718<td class="cellrowborder" valign="top" width="82.99%" headers="mcps1.1.3.1.2 "><p id="zh-cn_topic_0000001117163542_p12584946115012"><a name="zh-cn_topic_0000001117163542_p12584946115012"></a><a name="zh-cn_topic_0000001117163542_p12584946115012"></a>无</p> 719</td> 720</tr> 721</tbody> 722</table> 723 724**示例:** 725 726``` 727store.get(key, 'test', function(err, data) { 728 console.info(data); 729}); 730``` 731 732## get\(key: string, defValue: ValueType\)<a name="zh-cn_topic_0000001117163542_section20585144614501"></a> 733 734获取键对应的值,如果值为null或者非默认值类型,返默认数据。 735 736此方法为异步方法。 737 738**参数:** 739 740<a name="zh-cn_topic_0000001117163542_table65864463507"></a> 741<table><thead align="left"><tr id="zh-cn_topic_0000001117163542_row65862461509"><th class="cellrowborder" valign="top" width="14.451487079473427%" id="mcps1.1.5.1.1"><p id="zh-cn_topic_0000001117163542_p95861446125014"><a name="zh-cn_topic_0000001117163542_p95861446125014"></a><a name="zh-cn_topic_0000001117163542_p95861446125014"></a>参数名</p> 742</th> 743<th class="cellrowborder" valign="top" width="18.95660653339834%" id="mcps1.1.5.1.2"><p id="zh-cn_topic_0000001117163542_p17586154611509"><a name="zh-cn_topic_0000001117163542_p17586154611509"></a><a name="zh-cn_topic_0000001117163542_p17586154611509"></a>类型</p> 744</th> 745<th class="cellrowborder" valign="top" width="6.825938566552901%" id="mcps1.1.5.1.3"><p id="zh-cn_topic_0000001117163542_p10586184616503"><a name="zh-cn_topic_0000001117163542_p10586184616503"></a><a name="zh-cn_topic_0000001117163542_p10586184616503"></a>必填</p> 746</th> 747<th class="cellrowborder" valign="top" width="59.76596782057533%" id="mcps1.1.5.1.4"><p id="zh-cn_topic_0000001117163542_p16586184613509"><a name="zh-cn_topic_0000001117163542_p16586184613509"></a><a name="zh-cn_topic_0000001117163542_p16586184613509"></a>说明</p> 748</th> 749</tr> 750</thead> 751<tbody><tr id="zh-cn_topic_0000001117163542_row125869461500"><td class="cellrowborder" valign="top" width="14.451487079473427%" headers="mcps1.1.5.1.1 "><p id="zh-cn_topic_0000001117163542_p1036113511718"><a name="zh-cn_topic_0000001117163542_p1036113511718"></a><a name="zh-cn_topic_0000001117163542_p1036113511718"></a>key</p> 752</td> 753<td class="cellrowborder" valign="top" width="18.95660653339834%" headers="mcps1.1.5.1.2 "><p id="zh-cn_topic_0000001117163542_p5586164645012"><a name="zh-cn_topic_0000001117163542_p5586164645012"></a><a name="zh-cn_topic_0000001117163542_p5586164645012"></a>string</p> 754</td> 755<td class="cellrowborder" valign="top" width="6.825938566552901%" headers="mcps1.1.5.1.3 "><p id="zh-cn_topic_0000001117163542_p8587134612503"><a name="zh-cn_topic_0000001117163542_p8587134612503"></a><a name="zh-cn_topic_0000001117163542_p8587134612503"></a>是</p> 756</td> 757<td class="cellrowborder" valign="top" width="59.76596782057533%" headers="mcps1.1.5.1.4 "><p id="zh-cn_topic_0000001117163542_p144662048512"><a name="zh-cn_topic_0000001117163542_p144662048512"></a><a name="zh-cn_topic_0000001117163542_p144662048512"></a>要获取的存储key名称。它不能为空。</p> 758</td> 759</tr> 760<tr id="zh-cn_topic_0000001117163542_row523692017711"><td class="cellrowborder" valign="top" width="14.451487079473427%" headers="mcps1.1.5.1.1 "><p id="zh-cn_topic_0000001117163542_p923722011713"><a name="zh-cn_topic_0000001117163542_p923722011713"></a><a name="zh-cn_topic_0000001117163542_p923722011713"></a>defValue</p> 761</td> 762<td class="cellrowborder" valign="top" width="18.95660653339834%" headers="mcps1.1.5.1.2 "><p id="zh-cn_topic_0000001117163542_p623720207718"><a name="zh-cn_topic_0000001117163542_p623720207718"></a><a name="zh-cn_topic_0000001117163542_p623720207718"></a>ValueType</p> 763</td> 764<td class="cellrowborder" valign="top" width="6.825938566552901%" headers="mcps1.1.5.1.3 "><p id="zh-cn_topic_0000001117163542_p1423712012715"><a name="zh-cn_topic_0000001117163542_p1423712012715"></a><a name="zh-cn_topic_0000001117163542_p1423712012715"></a>是</p> 765</td> 766<td class="cellrowborder" valign="top" width="59.76596782057533%" headers="mcps1.1.5.1.4 "><p id="zh-cn_topic_0000001117163542_p72371420979"><a name="zh-cn_topic_0000001117163542_p72371420979"></a><a name="zh-cn_topic_0000001117163542_p72371420979"></a>默认返回值。支持number 、 string 、boolean。</p> 767</td> 768</tr> 769</tbody> 770</table> 771 772**返回值:** 773 774<a name="zh-cn_topic_0000001117163542_table155871846155019"></a> 775<table><thead align="left"><tr id="zh-cn_topic_0000001117163542_row658774619501"><th class="cellrowborder" valign="top" width="17.01%" id="mcps1.1.3.1.1"><p id="zh-cn_topic_0000001117163542_p058744635010"><a name="zh-cn_topic_0000001117163542_p058744635010"></a><a name="zh-cn_topic_0000001117163542_p058744635010"></a>类型</p> 776</th> 777<th class="cellrowborder" valign="top" width="82.99%" id="mcps1.1.3.1.2"><p id="zh-cn_topic_0000001117163542_p55871846165014"><a name="zh-cn_topic_0000001117163542_p55871846165014"></a><a name="zh-cn_topic_0000001117163542_p55871846165014"></a>说明</p> 778</th> 779</tr> 780</thead> 781<tbody><tr id="zh-cn_topic_0000001117163542_row125871346115018"><td class="cellrowborder" valign="top" width="17.01%" headers="mcps1.1.3.1.1 "><p id="zh-cn_topic_0000001117163542_p1161215410715"><a name="zh-cn_topic_0000001117163542_p1161215410715"></a><a name="zh-cn_topic_0000001117163542_p1161215410715"></a>Promise<ValueType></p> 782</td> 783<td class="cellrowborder" valign="top" width="82.99%" headers="mcps1.1.3.1.2 "><p id="zh-cn_topic_0000001117163542_p156121754178"><a name="zh-cn_topic_0000001117163542_p156121754178"></a><a name="zh-cn_topic_0000001117163542_p156121754178"></a>Promise实例,用于异步获取结果。</p> 784</td> 785</tr> 786</tbody> 787</table> 788 789**示例:** 790 791``` 792const promise = store.get(key, 'test'); 793promise.then((data) => { 794 console.info(data); 795 }).catch((err) => { 796}); 797``` 798 799## putSync\(key: string, value: ValueType\)<a name="zh-cn_topic_0000001117163542_section428912524119"></a> 800 801首先获取指定文件对应的Storage实例,然后借助Storage API将数据写入Storage实例,通过flush或者flushSync将Storage实例持久化。 802 803此方法为同步方法。 804 805**参数:** 806 807<a name="zh-cn_topic_0000001117163542_table229055221119"></a> 808<table><thead align="left"><tr id="zh-cn_topic_0000001117163542_row329017524114"><th class="cellrowborder" valign="top" width="14.82%" id="mcps1.1.5.1.1"><p id="zh-cn_topic_0000001117163542_p629055213110"><a name="zh-cn_topic_0000001117163542_p629055213110"></a><a name="zh-cn_topic_0000001117163542_p629055213110"></a>参数名</p> 809</th> 810<th class="cellrowborder" valign="top" width="14.729999999999999%" id="mcps1.1.5.1.2"><p id="zh-cn_topic_0000001117163542_p18290145251111"><a name="zh-cn_topic_0000001117163542_p18290145251111"></a><a name="zh-cn_topic_0000001117163542_p18290145251111"></a>类型</p> 811</th> 812<th class="cellrowborder" valign="top" width="9.16%" id="mcps1.1.5.1.3"><p id="zh-cn_topic_0000001117163542_p1429114526111"><a name="zh-cn_topic_0000001117163542_p1429114526111"></a><a name="zh-cn_topic_0000001117163542_p1429114526111"></a>必填</p> 813</th> 814<th class="cellrowborder" valign="top" width="61.29%" id="mcps1.1.5.1.4"><p id="zh-cn_topic_0000001117163542_p929125218119"><a name="zh-cn_topic_0000001117163542_p929125218119"></a><a name="zh-cn_topic_0000001117163542_p929125218119"></a>说明</p> 815</th> 816</tr> 817</thead> 818<tbody><tr id="zh-cn_topic_0000001117163542_row829195216111"><td class="cellrowborder" valign="top" width="14.82%" headers="mcps1.1.5.1.1 "><p id="zh-cn_topic_0000001117163542_p629135261117"><a name="zh-cn_topic_0000001117163542_p629135261117"></a><a name="zh-cn_topic_0000001117163542_p629135261117"></a>key</p> 819</td> 820<td class="cellrowborder" valign="top" width="14.729999999999999%" headers="mcps1.1.5.1.2 "><p id="zh-cn_topic_0000001117163542_p52911852101111"><a name="zh-cn_topic_0000001117163542_p52911852101111"></a><a name="zh-cn_topic_0000001117163542_p52911852101111"></a>string</p> 821</td> 822<td class="cellrowborder" valign="top" width="9.16%" headers="mcps1.1.5.1.3 "><p id="zh-cn_topic_0000001117163542_p829117529115"><a name="zh-cn_topic_0000001117163542_p829117529115"></a><a name="zh-cn_topic_0000001117163542_p829117529115"></a>是</p> 823</td> 824<td class="cellrowborder" valign="top" width="61.29%" headers="mcps1.1.5.1.4 "><p id="zh-cn_topic_0000001117163542_p1292752131120"><a name="zh-cn_topic_0000001117163542_p1292752131120"></a><a name="zh-cn_topic_0000001117163542_p1292752131120"></a>要修改的存储的key。它不能为空。</p> 825</td> 826</tr> 827<tr id="zh-cn_topic_0000001117163542_row192924526111"><td class="cellrowborder" valign="top" width="14.82%" headers="mcps1.1.5.1.1 "><p id="zh-cn_topic_0000001117163542_p6292165215113"><a name="zh-cn_topic_0000001117163542_p6292165215113"></a><a name="zh-cn_topic_0000001117163542_p6292165215113"></a>value</p> 828</td> 829<td class="cellrowborder" valign="top" width="14.729999999999999%" headers="mcps1.1.5.1.2 "><p id="zh-cn_topic_0000001117163542_p12292155201112"><a name="zh-cn_topic_0000001117163542_p12292155201112"></a><a name="zh-cn_topic_0000001117163542_p12292155201112"></a>ValueType</p> 830</td> 831<td class="cellrowborder" valign="top" width="9.16%" headers="mcps1.1.5.1.3 "><p id="zh-cn_topic_0000001117163542_p1629255217118"><a name="zh-cn_topic_0000001117163542_p1629255217118"></a><a name="zh-cn_topic_0000001117163542_p1629255217118"></a>是</p> 832</td> 833<td class="cellrowborder" valign="top" width="61.29%" headers="mcps1.1.5.1.4 "><p id="zh-cn_topic_0000001117163542_p16293145217114"><a name="zh-cn_topic_0000001117163542_p16293145217114"></a><a name="zh-cn_topic_0000001117163542_p16293145217114"></a>存储的新值。支持number 、 string 、boolean。</p> 834</td> 835</tr> 836</tbody> 837</table> 838 839**返回值:** 840 841<a name="zh-cn_topic_0000001117163542_table82931952151110"></a> 842<table><thead align="left"><tr id="zh-cn_topic_0000001117163542_row729314527114"><th class="cellrowborder" valign="top" width="17.01%" id="mcps1.1.3.1.1"><p id="zh-cn_topic_0000001117163542_p1229355220111"><a name="zh-cn_topic_0000001117163542_p1229355220111"></a><a name="zh-cn_topic_0000001117163542_p1229355220111"></a>类型</p> 843</th> 844<th class="cellrowborder" valign="top" width="82.99%" id="mcps1.1.3.1.2"><p id="zh-cn_topic_0000001117163542_p7294105261117"><a name="zh-cn_topic_0000001117163542_p7294105261117"></a><a name="zh-cn_topic_0000001117163542_p7294105261117"></a>说明</p> 845</th> 846</tr> 847</thead> 848<tbody><tr id="zh-cn_topic_0000001117163542_row5294252171116"><td class="cellrowborder" valign="top" width="17.01%" headers="mcps1.1.3.1.1 "><p id="zh-cn_topic_0000001117163542_p15294155220112"><a name="zh-cn_topic_0000001117163542_p15294155220112"></a><a name="zh-cn_topic_0000001117163542_p15294155220112"></a>void</p> 849</td> 850<td class="cellrowborder" valign="top" width="82.99%" headers="mcps1.1.3.1.2 "><p id="zh-cn_topic_0000001117163542_p1294145271120"><a name="zh-cn_topic_0000001117163542_p1294145271120"></a><a name="zh-cn_topic_0000001117163542_p1294145271120"></a>无</p> 851</td> 852</tr> 853</tbody> 854</table> 855 856**示例:** 857 858``` 859let data = store.putSync(key, ‘defValue’); 860``` 861 862## put\(key: string, value: ValueType, callback: AsyncCallback<void\>\)<a name="zh-cn_topic_0000001117163542_section92951552111117"></a> 863 864首先获取指定文件对应的Storage实例,然后借助Storage API将数据写入Storage实例,通过flush或者flushSync将Storage实例持久化。 865 866此方法为异步方法。 867 868**参数:** 869 870<a name="zh-cn_topic_0000001117163542_table1329585231117"></a> 871<table><thead align="left"><tr id="zh-cn_topic_0000001117163542_row122969526117"><th class="cellrowborder" valign="top" width="14.451487079473427%" id="mcps1.1.5.1.1"><p id="zh-cn_topic_0000001117163542_p029695210117"><a name="zh-cn_topic_0000001117163542_p029695210117"></a><a name="zh-cn_topic_0000001117163542_p029695210117"></a>参数名</p> 872</th> 873<th class="cellrowborder" valign="top" width="18.95660653339834%" id="mcps1.1.5.1.2"><p id="zh-cn_topic_0000001117163542_p102961152141113"><a name="zh-cn_topic_0000001117163542_p102961152141113"></a><a name="zh-cn_topic_0000001117163542_p102961152141113"></a>类型</p> 874</th> 875<th class="cellrowborder" valign="top" width="6.825938566552901%" id="mcps1.1.5.1.3"><p id="zh-cn_topic_0000001117163542_p2296195251119"><a name="zh-cn_topic_0000001117163542_p2296195251119"></a><a name="zh-cn_topic_0000001117163542_p2296195251119"></a>必填</p> 876</th> 877<th class="cellrowborder" valign="top" width="59.76596782057533%" id="mcps1.1.5.1.4"><p id="zh-cn_topic_0000001117163542_p1829695214114"><a name="zh-cn_topic_0000001117163542_p1829695214114"></a><a name="zh-cn_topic_0000001117163542_p1829695214114"></a>说明</p> 878</th> 879</tr> 880</thead> 881<tbody><tr id="zh-cn_topic_0000001117163542_row1029717529113"><td class="cellrowborder" valign="top" width="14.451487079473427%" headers="mcps1.1.5.1.1 "><p id="zh-cn_topic_0000001117163542_p629715219113"><a name="zh-cn_topic_0000001117163542_p629715219113"></a><a name="zh-cn_topic_0000001117163542_p629715219113"></a>key</p> 882</td> 883<td class="cellrowborder" valign="top" width="18.95660653339834%" headers="mcps1.1.5.1.2 "><p id="zh-cn_topic_0000001117163542_p10297952101120"><a name="zh-cn_topic_0000001117163542_p10297952101120"></a><a name="zh-cn_topic_0000001117163542_p10297952101120"></a>string</p> 884</td> 885<td class="cellrowborder" valign="top" width="6.825938566552901%" headers="mcps1.1.5.1.3 "><p id="zh-cn_topic_0000001117163542_p329785218115"><a name="zh-cn_topic_0000001117163542_p329785218115"></a><a name="zh-cn_topic_0000001117163542_p329785218115"></a>是</p> 886</td> 887<td class="cellrowborder" valign="top" width="59.76596782057533%" headers="mcps1.1.5.1.4 "><p id="zh-cn_topic_0000001117163542_p15240135384910"><a name="zh-cn_topic_0000001117163542_p15240135384910"></a><a name="zh-cn_topic_0000001117163542_p15240135384910"></a>要修改的存储的key。它不能为空。</p> 888</td> 889</tr> 890<tr id="zh-cn_topic_0000001117163542_row16297052141116"><td class="cellrowborder" valign="top" width="14.451487079473427%" headers="mcps1.1.5.1.1 "><p id="zh-cn_topic_0000001117163542_p14297185211116"><a name="zh-cn_topic_0000001117163542_p14297185211116"></a><a name="zh-cn_topic_0000001117163542_p14297185211116"></a>value</p> 891</td> 892<td class="cellrowborder" valign="top" width="18.95660653339834%" headers="mcps1.1.5.1.2 "><p id="zh-cn_topic_0000001117163542_p6297852181115"><a name="zh-cn_topic_0000001117163542_p6297852181115"></a><a name="zh-cn_topic_0000001117163542_p6297852181115"></a>ValueType</p> 893</td> 894<td class="cellrowborder" valign="top" width="6.825938566552901%" headers="mcps1.1.5.1.3 "><p id="zh-cn_topic_0000001117163542_p0298752101117"><a name="zh-cn_topic_0000001117163542_p0298752101117"></a><a name="zh-cn_topic_0000001117163542_p0298752101117"></a>是</p> 895</td> 896<td class="cellrowborder" valign="top" width="59.76596782057533%" headers="mcps1.1.5.1.4 "><p id="zh-cn_topic_0000001117163542_p12298165211113"><a name="zh-cn_topic_0000001117163542_p12298165211113"></a><a name="zh-cn_topic_0000001117163542_p12298165211113"></a>存储的新值。支持number 、 string 、boolean。</p> 897</td> 898</tr> 899<tr id="zh-cn_topic_0000001117163542_row029835211117"><td class="cellrowborder" valign="top" width="14.451487079473427%" headers="mcps1.1.5.1.1 "><p id="zh-cn_topic_0000001117163542_p15298115216111"><a name="zh-cn_topic_0000001117163542_p15298115216111"></a><a name="zh-cn_topic_0000001117163542_p15298115216111"></a>callback</p> 900</td> 901<td class="cellrowborder" valign="top" width="18.95660653339834%" headers="mcps1.1.5.1.2 "><p id="zh-cn_topic_0000001117163542_p1729815220113"><a name="zh-cn_topic_0000001117163542_p1729815220113"></a><a name="zh-cn_topic_0000001117163542_p1729815220113"></a>AsyncCallback<void></p> 902</td> 903<td class="cellrowborder" valign="top" width="6.825938566552901%" headers="mcps1.1.5.1.3 "><p id="zh-cn_topic_0000001117163542_p22981152141120"><a name="zh-cn_topic_0000001117163542_p22981152141120"></a><a name="zh-cn_topic_0000001117163542_p22981152141120"></a>是</p> 904</td> 905<td class="cellrowborder" valign="top" width="59.76596782057533%" headers="mcps1.1.5.1.4 "><p id="zh-cn_topic_0000001117163542_p529865281113"><a name="zh-cn_topic_0000001117163542_p529865281113"></a><a name="zh-cn_topic_0000001117163542_p529865281113"></a>回调函数。</p> 906</td> 907</tr> 908</tbody> 909</table> 910 911**返回值:** 912 913<a name="zh-cn_topic_0000001117163542_table1329935291111"></a> 914<table><thead align="left"><tr id="zh-cn_topic_0000001117163542_row129915281114"><th class="cellrowborder" valign="top" width="17.01%" id="mcps1.1.3.1.1"><p id="zh-cn_topic_0000001117163542_p1129918526117"><a name="zh-cn_topic_0000001117163542_p1129918526117"></a><a name="zh-cn_topic_0000001117163542_p1129918526117"></a>类型</p> 915</th> 916<th class="cellrowborder" valign="top" width="82.99%" id="mcps1.1.3.1.2"><p id="zh-cn_topic_0000001117163542_p1429985291110"><a name="zh-cn_topic_0000001117163542_p1429985291110"></a><a name="zh-cn_topic_0000001117163542_p1429985291110"></a>说明</p> 917</th> 918</tr> 919</thead> 920<tbody><tr id="zh-cn_topic_0000001117163542_row4299205231112"><td class="cellrowborder" valign="top" width="17.01%" headers="mcps1.1.3.1.1 "><p id="zh-cn_topic_0000001117163542_p1129905201116"><a name="zh-cn_topic_0000001117163542_p1129905201116"></a><a name="zh-cn_topic_0000001117163542_p1129905201116"></a>void</p> 921</td> 922<td class="cellrowborder" valign="top" width="82.99%" headers="mcps1.1.3.1.2 "><p id="zh-cn_topic_0000001117163542_p1629935211116"><a name="zh-cn_topic_0000001117163542_p1629935211116"></a><a name="zh-cn_topic_0000001117163542_p1629935211116"></a>无</p> 923</td> 924</tr> 925</tbody> 926</table> 927 928**示例:** 929 930``` 931store.put(key, 'test', function(err, data) { 932}); 933``` 934 935## put\(key: string, value: ValueType\)<a name="zh-cn_topic_0000001117163542_section230117522119"></a> 936 937首先获取指定文件对应的Storage实例,然后借助Storage API将数据写入Storage实例,通过flush或者flushSync将Storage实例持久化。 938 939此方法为异步方法。 940 941**参数:** 942 943<a name="zh-cn_topic_0000001117163542_table12302052171118"></a> 944<table><thead align="left"><tr id="zh-cn_topic_0000001117163542_row83028525117"><th class="cellrowborder" valign="top" width="14.451487079473427%" id="mcps1.1.5.1.1"><p id="zh-cn_topic_0000001117163542_p1302105251110"><a name="zh-cn_topic_0000001117163542_p1302105251110"></a><a name="zh-cn_topic_0000001117163542_p1302105251110"></a>参数名</p> 945</th> 946<th class="cellrowborder" valign="top" width="18.95660653339834%" id="mcps1.1.5.1.2"><p id="zh-cn_topic_0000001117163542_p030255215112"><a name="zh-cn_topic_0000001117163542_p030255215112"></a><a name="zh-cn_topic_0000001117163542_p030255215112"></a>类型</p> 947</th> 948<th class="cellrowborder" valign="top" width="6.825938566552901%" id="mcps1.1.5.1.3"><p id="zh-cn_topic_0000001117163542_p2303125281116"><a name="zh-cn_topic_0000001117163542_p2303125281116"></a><a name="zh-cn_topic_0000001117163542_p2303125281116"></a>必填</p> 949</th> 950<th class="cellrowborder" valign="top" width="59.76596782057533%" id="mcps1.1.5.1.4"><p id="zh-cn_topic_0000001117163542_p33030523118"><a name="zh-cn_topic_0000001117163542_p33030523118"></a><a name="zh-cn_topic_0000001117163542_p33030523118"></a>说明</p> 951</th> 952</tr> 953</thead> 954<tbody><tr id="zh-cn_topic_0000001117163542_row11303135212119"><td class="cellrowborder" valign="top" width="14.451487079473427%" headers="mcps1.1.5.1.1 "><p id="zh-cn_topic_0000001117163542_p3303115281110"><a name="zh-cn_topic_0000001117163542_p3303115281110"></a><a name="zh-cn_topic_0000001117163542_p3303115281110"></a>key</p> 955</td> 956<td class="cellrowborder" valign="top" width="18.95660653339834%" headers="mcps1.1.5.1.2 "><p id="zh-cn_topic_0000001117163542_p16303195221112"><a name="zh-cn_topic_0000001117163542_p16303195221112"></a><a name="zh-cn_topic_0000001117163542_p16303195221112"></a>string</p> 957</td> 958<td class="cellrowborder" valign="top" width="6.825938566552901%" headers="mcps1.1.5.1.3 "><p id="zh-cn_topic_0000001117163542_p230435211116"><a name="zh-cn_topic_0000001117163542_p230435211116"></a><a name="zh-cn_topic_0000001117163542_p230435211116"></a>是</p> 959</td> 960<td class="cellrowborder" valign="top" width="59.76596782057533%" headers="mcps1.1.5.1.4 "><p id="zh-cn_topic_0000001117163542_p258165814496"><a name="zh-cn_topic_0000001117163542_p258165814496"></a><a name="zh-cn_topic_0000001117163542_p258165814496"></a>要修改的存储的key。它不能为空。</p> 961</td> 962</tr> 963<tr id="zh-cn_topic_0000001117163542_row7304205213110"><td class="cellrowborder" valign="top" width="14.451487079473427%" headers="mcps1.1.5.1.1 "><p id="zh-cn_topic_0000001117163542_p230412521118"><a name="zh-cn_topic_0000001117163542_p230412521118"></a><a name="zh-cn_topic_0000001117163542_p230412521118"></a>value</p> 964</td> 965<td class="cellrowborder" valign="top" width="18.95660653339834%" headers="mcps1.1.5.1.2 "><p id="zh-cn_topic_0000001117163542_p930485251119"><a name="zh-cn_topic_0000001117163542_p930485251119"></a><a name="zh-cn_topic_0000001117163542_p930485251119"></a>ValueType</p> 966</td> 967<td class="cellrowborder" valign="top" width="6.825938566552901%" headers="mcps1.1.5.1.3 "><p id="zh-cn_topic_0000001117163542_p830445201113"><a name="zh-cn_topic_0000001117163542_p830445201113"></a><a name="zh-cn_topic_0000001117163542_p830445201113"></a>是</p> 968</td> 969<td class="cellrowborder" valign="top" width="59.76596782057533%" headers="mcps1.1.5.1.4 "><p id="zh-cn_topic_0000001117163542_p20305105261112"><a name="zh-cn_topic_0000001117163542_p20305105261112"></a><a name="zh-cn_topic_0000001117163542_p20305105261112"></a>存储的新值。支持number 、 string 、boolean。</p> 970</td> 971</tr> 972</tbody> 973</table> 974 975**返回值:** 976 977<a name="zh-cn_topic_0000001117163542_table23054526111"></a> 978<table><thead align="left"><tr id="zh-cn_topic_0000001117163542_row113051252131111"><th class="cellrowborder" valign="top" width="17.01%" id="mcps1.1.3.1.1"><p id="zh-cn_topic_0000001117163542_p3305552171115"><a name="zh-cn_topic_0000001117163542_p3305552171115"></a><a name="zh-cn_topic_0000001117163542_p3305552171115"></a>类型</p> 979</th> 980<th class="cellrowborder" valign="top" width="82.99%" id="mcps1.1.3.1.2"><p id="zh-cn_topic_0000001117163542_p13061052181112"><a name="zh-cn_topic_0000001117163542_p13061052181112"></a><a name="zh-cn_topic_0000001117163542_p13061052181112"></a>说明</p> 981</th> 982</tr> 983</thead> 984<tbody><tr id="zh-cn_topic_0000001117163542_row1630610528116"><td class="cellrowborder" valign="top" width="17.01%" headers="mcps1.1.3.1.1 "><p id="zh-cn_topic_0000001117163542_p066915611810"><a name="zh-cn_topic_0000001117163542_p066915611810"></a><a name="zh-cn_topic_0000001117163542_p066915611810"></a>Promise<void></p> 985</td> 986<td class="cellrowborder" valign="top" width="82.99%" headers="mcps1.1.3.1.2 "><p id="zh-cn_topic_0000001117163542_p176691961886"><a name="zh-cn_topic_0000001117163542_p176691961886"></a><a name="zh-cn_topic_0000001117163542_p176691961886"></a>Promise实例,用于异步处理。</p> 987</td> 988</tr> 989</tbody> 990</table> 991 992**示例:** 993 994``` 995const promise = store.put(key, 'test'); 996promise.then((data) => { 997 }).catch((err) => { 998}); 999``` 1000 1001## hasSync\(key: string\)<a name="zh-cn_topic_0000001117163542_section0884174321910"></a> 1002 1003检查存储对象是否包含名为给定key的存储。 1004 1005此方法为同步方法。 1006 1007**参数:** 1008 1009<a name="zh-cn_topic_0000001117163542_table6884134310199"></a> 1010<table><thead align="left"><tr id="zh-cn_topic_0000001117163542_row1888514331911"><th class="cellrowborder" valign="top" width="14.82%" id="mcps1.1.5.1.1"><p id="zh-cn_topic_0000001117163542_p1188534311198"><a name="zh-cn_topic_0000001117163542_p1188534311198"></a><a name="zh-cn_topic_0000001117163542_p1188534311198"></a>参数名</p> 1011</th> 1012<th class="cellrowborder" valign="top" width="14.729999999999999%" id="mcps1.1.5.1.2"><p id="zh-cn_topic_0000001117163542_p788534310194"><a name="zh-cn_topic_0000001117163542_p788534310194"></a><a name="zh-cn_topic_0000001117163542_p788534310194"></a>类型</p> 1013</th> 1014<th class="cellrowborder" valign="top" width="9.16%" id="mcps1.1.5.1.3"><p id="zh-cn_topic_0000001117163542_p98857435197"><a name="zh-cn_topic_0000001117163542_p98857435197"></a><a name="zh-cn_topic_0000001117163542_p98857435197"></a>必填</p> 1015</th> 1016<th class="cellrowborder" valign="top" width="61.29%" id="mcps1.1.5.1.4"><p id="zh-cn_topic_0000001117163542_p28851643161916"><a name="zh-cn_topic_0000001117163542_p28851643161916"></a><a name="zh-cn_topic_0000001117163542_p28851643161916"></a>说明</p> 1017</th> 1018</tr> 1019</thead> 1020<tbody><tr id="zh-cn_topic_0000001117163542_row7885114301920"><td class="cellrowborder" valign="top" width="14.82%" headers="mcps1.1.5.1.1 "><p id="zh-cn_topic_0000001117163542_p1188574311190"><a name="zh-cn_topic_0000001117163542_p1188574311190"></a><a name="zh-cn_topic_0000001117163542_p1188574311190"></a>key</p> 1021</td> 1022<td class="cellrowborder" valign="top" width="14.729999999999999%" headers="mcps1.1.5.1.2 "><p id="zh-cn_topic_0000001117163542_p2088664320193"><a name="zh-cn_topic_0000001117163542_p2088664320193"></a><a name="zh-cn_topic_0000001117163542_p2088664320193"></a>string</p> 1023</td> 1024<td class="cellrowborder" valign="top" width="9.16%" headers="mcps1.1.5.1.3 "><p id="zh-cn_topic_0000001117163542_p18861943111912"><a name="zh-cn_topic_0000001117163542_p18861943111912"></a><a name="zh-cn_topic_0000001117163542_p18861943111912"></a>是</p> 1025</td> 1026<td class="cellrowborder" valign="top" width="61.29%" headers="mcps1.1.5.1.4 "><p id="zh-cn_topic_0000001117163542_p103221766219"><a name="zh-cn_topic_0000001117163542_p103221766219"></a><a name="zh-cn_topic_0000001117163542_p103221766219"></a>要获取的存储key名称。它不能为空。</p> 1027</td> 1028</tr> 1029</tbody> 1030</table> 1031 1032**返回值:** 1033 1034<a name="zh-cn_topic_0000001117163542_table12887134318193"></a> 1035<table><thead align="left"><tr id="zh-cn_topic_0000001117163542_row158872043101914"><th class="cellrowborder" valign="top" width="17.01%" id="mcps1.1.3.1.1"><p id="zh-cn_topic_0000001117163542_p0887174314197"><a name="zh-cn_topic_0000001117163542_p0887174314197"></a><a name="zh-cn_topic_0000001117163542_p0887174314197"></a>类型</p> 1036</th> 1037<th class="cellrowborder" valign="top" width="82.99%" id="mcps1.1.3.1.2"><p id="zh-cn_topic_0000001117163542_p1988744314199"><a name="zh-cn_topic_0000001117163542_p1988744314199"></a><a name="zh-cn_topic_0000001117163542_p1988744314199"></a>说明</p> 1038</th> 1039</tr> 1040</thead> 1041<tbody><tr id="zh-cn_topic_0000001117163542_row16887443131910"><td class="cellrowborder" valign="top" width="17.01%" headers="mcps1.1.3.1.1 "><p id="zh-cn_topic_0000001117163542_p0888184310199"><a name="zh-cn_topic_0000001117163542_p0888184310199"></a><a name="zh-cn_topic_0000001117163542_p0888184310199"></a>boolean</p> 1042</td> 1043<td class="cellrowborder" valign="top" width="82.99%" headers="mcps1.1.3.1.2 "><p id="zh-cn_topic_0000001117163542_p3888124331919"><a name="zh-cn_topic_0000001117163542_p3888124331919"></a><a name="zh-cn_topic_0000001117163542_p3888124331919"></a>true 表示存在,false表示不存在</p> 1044</td> 1045</tr> 1046</tbody> 1047</table> 1048 1049**示例:** 1050 1051``` 1052let ret = store.hasSync(key); 1053``` 1054 1055## has\(key: string, callback: AsyncCallback<boolean\>\)<a name="zh-cn_topic_0000001117163542_section1889144312199"></a> 1056 1057检查存储对象是否包含名为给定key的存储。 1058 1059此方法为异步方法。 1060 1061**参数:** 1062 1063<a name="zh-cn_topic_0000001117163542_table12889114351915"></a> 1064<table><thead align="left"><tr id="zh-cn_topic_0000001117163542_row1289014316196"><th class="cellrowborder" valign="top" width="14.451487079473427%" id="mcps1.1.5.1.1"><p id="zh-cn_topic_0000001117163542_p18890144381915"><a name="zh-cn_topic_0000001117163542_p18890144381915"></a><a name="zh-cn_topic_0000001117163542_p18890144381915"></a>参数名</p> 1065</th> 1066<th class="cellrowborder" valign="top" width="18.95660653339834%" id="mcps1.1.5.1.2"><p id="zh-cn_topic_0000001117163542_p11890164341910"><a name="zh-cn_topic_0000001117163542_p11890164341910"></a><a name="zh-cn_topic_0000001117163542_p11890164341910"></a>类型</p> 1067</th> 1068<th class="cellrowborder" valign="top" width="6.825938566552901%" id="mcps1.1.5.1.3"><p id="zh-cn_topic_0000001117163542_p9890184312190"><a name="zh-cn_topic_0000001117163542_p9890184312190"></a><a name="zh-cn_topic_0000001117163542_p9890184312190"></a>必填</p> 1069</th> 1070<th class="cellrowborder" valign="top" width="59.76596782057533%" id="mcps1.1.5.1.4"><p id="zh-cn_topic_0000001117163542_p198907438198"><a name="zh-cn_topic_0000001117163542_p198907438198"></a><a name="zh-cn_topic_0000001117163542_p198907438198"></a>说明</p> 1071</th> 1072</tr> 1073</thead> 1074<tbody><tr id="zh-cn_topic_0000001117163542_row18890104361917"><td class="cellrowborder" valign="top" width="14.451487079473427%" headers="mcps1.1.5.1.1 "><p id="zh-cn_topic_0000001117163542_p7890184317194"><a name="zh-cn_topic_0000001117163542_p7890184317194"></a><a name="zh-cn_topic_0000001117163542_p7890184317194"></a>key</p> 1075</td> 1076<td class="cellrowborder" valign="top" width="18.95660653339834%" headers="mcps1.1.5.1.2 "><p id="zh-cn_topic_0000001117163542_p14890114314192"><a name="zh-cn_topic_0000001117163542_p14890114314192"></a><a name="zh-cn_topic_0000001117163542_p14890114314192"></a>string</p> 1077</td> 1078<td class="cellrowborder" valign="top" width="6.825938566552901%" headers="mcps1.1.5.1.3 "><p id="zh-cn_topic_0000001117163542_p98919431199"><a name="zh-cn_topic_0000001117163542_p98919431199"></a><a name="zh-cn_topic_0000001117163542_p98919431199"></a>是</p> 1079</td> 1080<td class="cellrowborder" valign="top" width="59.76596782057533%" headers="mcps1.1.5.1.4 "><p id="zh-cn_topic_0000001117163542_p13891174310191"><a name="zh-cn_topic_0000001117163542_p13891174310191"></a><a name="zh-cn_topic_0000001117163542_p13891174310191"></a>要获取的存储key名称。它不能为空。</p> 1081</td> 1082</tr> 1083<tr id="zh-cn_topic_0000001117163542_row1989114312192"><td class="cellrowborder" valign="top" width="14.451487079473427%" headers="mcps1.1.5.1.1 "><p id="zh-cn_topic_0000001117163542_p989104361918"><a name="zh-cn_topic_0000001117163542_p989104361918"></a><a name="zh-cn_topic_0000001117163542_p989104361918"></a>callback</p> 1084</td> 1085<td class="cellrowborder" valign="top" width="18.95660653339834%" headers="mcps1.1.5.1.2 "><p id="zh-cn_topic_0000001117163542_p789224351918"><a name="zh-cn_topic_0000001117163542_p789224351918"></a><a name="zh-cn_topic_0000001117163542_p789224351918"></a>AsyncCallback<boolean></p> 1086</td> 1087<td class="cellrowborder" valign="top" width="6.825938566552901%" headers="mcps1.1.5.1.3 "><p id="zh-cn_topic_0000001117163542_p13892134315194"><a name="zh-cn_topic_0000001117163542_p13892134315194"></a><a name="zh-cn_topic_0000001117163542_p13892134315194"></a>是</p> 1088</td> 1089<td class="cellrowborder" valign="top" width="59.76596782057533%" headers="mcps1.1.5.1.4 "><p id="zh-cn_topic_0000001117163542_p1089284318198"><a name="zh-cn_topic_0000001117163542_p1089284318198"></a><a name="zh-cn_topic_0000001117163542_p1089284318198"></a>回调函数。</p> 1090</td> 1091</tr> 1092</tbody> 1093</table> 1094 1095**返回值:** 1096 1097<a name="zh-cn_topic_0000001117163542_table178921243171920"></a> 1098<table><thead align="left"><tr id="zh-cn_topic_0000001117163542_row48921643151917"><th class="cellrowborder" valign="top" width="17.01%" id="mcps1.1.3.1.1"><p id="zh-cn_topic_0000001117163542_p188921843111911"><a name="zh-cn_topic_0000001117163542_p188921843111911"></a><a name="zh-cn_topic_0000001117163542_p188921843111911"></a>类型</p> 1099</th> 1100<th class="cellrowborder" valign="top" width="82.99%" id="mcps1.1.3.1.2"><p id="zh-cn_topic_0000001117163542_p1989304317191"><a name="zh-cn_topic_0000001117163542_p1989304317191"></a><a name="zh-cn_topic_0000001117163542_p1989304317191"></a>说明</p> 1101</th> 1102</tr> 1103</thead> 1104<tbody><tr id="zh-cn_topic_0000001117163542_row489374371912"><td class="cellrowborder" valign="top" width="17.01%" headers="mcps1.1.3.1.1 "><p id="zh-cn_topic_0000001117163542_p12893104331913"><a name="zh-cn_topic_0000001117163542_p12893104331913"></a><a name="zh-cn_topic_0000001117163542_p12893104331913"></a>boolean</p> 1105</td> 1106<td class="cellrowborder" valign="top" width="82.99%" headers="mcps1.1.3.1.2 "><p id="zh-cn_topic_0000001117163542_p389312439198"><a name="zh-cn_topic_0000001117163542_p389312439198"></a><a name="zh-cn_topic_0000001117163542_p389312439198"></a>true 表示存在,false表示不存在。</p> 1107</td> 1108</tr> 1109</tbody> 1110</table> 1111 1112**示例:** 1113 1114``` 1115store.has(key, function(err, data) { 1116 console.info(data); 1117}); 1118``` 1119 1120## has\(key: string\)<a name="zh-cn_topic_0000001117163542_section19894343121917"></a> 1121 1122检查存储对象是否包含名为给定key的存储。 1123 1124此方法为异步方法。 1125 1126**参数:** 1127 1128<a name="zh-cn_topic_0000001117163542_table389515434199"></a> 1129<table><thead align="left"><tr id="zh-cn_topic_0000001117163542_row489504371914"><th class="cellrowborder" valign="top" width="14.451487079473427%" id="mcps1.1.5.1.1"><p id="zh-cn_topic_0000001117163542_p12895443151919"><a name="zh-cn_topic_0000001117163542_p12895443151919"></a><a name="zh-cn_topic_0000001117163542_p12895443151919"></a>参数名</p> 1130</th> 1131<th class="cellrowborder" valign="top" width="18.95660653339834%" id="mcps1.1.5.1.2"><p id="zh-cn_topic_0000001117163542_p10895144316197"><a name="zh-cn_topic_0000001117163542_p10895144316197"></a><a name="zh-cn_topic_0000001117163542_p10895144316197"></a>类型</p> 1132</th> 1133<th class="cellrowborder" valign="top" width="6.825938566552901%" id="mcps1.1.5.1.3"><p id="zh-cn_topic_0000001117163542_p1789584317196"><a name="zh-cn_topic_0000001117163542_p1789584317196"></a><a name="zh-cn_topic_0000001117163542_p1789584317196"></a>必填</p> 1134</th> 1135<th class="cellrowborder" valign="top" width="59.76596782057533%" id="mcps1.1.5.1.4"><p id="zh-cn_topic_0000001117163542_p8896144391910"><a name="zh-cn_topic_0000001117163542_p8896144391910"></a><a name="zh-cn_topic_0000001117163542_p8896144391910"></a>说明</p> 1136</th> 1137</tr> 1138</thead> 1139<tbody><tr id="zh-cn_topic_0000001117163542_row189684331913"><td class="cellrowborder" valign="top" width="14.451487079473427%" headers="mcps1.1.5.1.1 "><p id="zh-cn_topic_0000001117163542_p4896154311919"><a name="zh-cn_topic_0000001117163542_p4896154311919"></a><a name="zh-cn_topic_0000001117163542_p4896154311919"></a>key</p> 1140</td> 1141<td class="cellrowborder" valign="top" width="18.95660653339834%" headers="mcps1.1.5.1.2 "><p id="zh-cn_topic_0000001117163542_p08962043161920"><a name="zh-cn_topic_0000001117163542_p08962043161920"></a><a name="zh-cn_topic_0000001117163542_p08962043161920"></a>string</p> 1142</td> 1143<td class="cellrowborder" valign="top" width="6.825938566552901%" headers="mcps1.1.5.1.3 "><p id="zh-cn_topic_0000001117163542_p089634311911"><a name="zh-cn_topic_0000001117163542_p089634311911"></a><a name="zh-cn_topic_0000001117163542_p089634311911"></a>是</p> 1144</td> 1145<td class="cellrowborder" valign="top" width="59.76596782057533%" headers="mcps1.1.5.1.4 "><p id="zh-cn_topic_0000001117163542_p7246147162517"><a name="zh-cn_topic_0000001117163542_p7246147162517"></a><a name="zh-cn_topic_0000001117163542_p7246147162517"></a>要获取的存储key名称。它不能为空。</p> 1146</td> 1147</tr> 1148</tbody> 1149</table> 1150 1151**返回值:** 1152 1153<a name="zh-cn_topic_0000001117163542_table489720437190"></a> 1154<table><thead align="left"><tr id="zh-cn_topic_0000001117163542_row48978431190"><th class="cellrowborder" valign="top" width="17.01%" id="mcps1.1.3.1.1"><p id="zh-cn_topic_0000001117163542_p189754341915"><a name="zh-cn_topic_0000001117163542_p189754341915"></a><a name="zh-cn_topic_0000001117163542_p189754341915"></a>类型</p> 1155</th> 1156<th class="cellrowborder" valign="top" width="82.99%" id="mcps1.1.3.1.2"><p id="zh-cn_topic_0000001117163542_p2898443141917"><a name="zh-cn_topic_0000001117163542_p2898443141917"></a><a name="zh-cn_topic_0000001117163542_p2898443141917"></a>说明</p> 1157</th> 1158</tr> 1159</thead> 1160<tbody><tr id="zh-cn_topic_0000001117163542_row1389884318191"><td class="cellrowborder" valign="top" width="17.01%" headers="mcps1.1.3.1.1 "><p id="zh-cn_topic_0000001117163542_p118141810812"><a name="zh-cn_topic_0000001117163542_p118141810812"></a><a name="zh-cn_topic_0000001117163542_p118141810812"></a>Promise<boolean></p> 1161</td> 1162<td class="cellrowborder" valign="top" width="82.99%" headers="mcps1.1.3.1.2 "><p id="zh-cn_topic_0000001117163542_p418114181385"><a name="zh-cn_topic_0000001117163542_p418114181385"></a><a name="zh-cn_topic_0000001117163542_p418114181385"></a>Promise实例,用于异步处理。</p> 1163</td> 1164</tr> 1165</tbody> 1166</table> 1167 1168**示例:** 1169 1170``` 1171const promise = store.has(key); 1172promise.then((data) => { 1173 console.info(data); 1174 }).catch((err) => { 1175}); 1176``` 1177 1178## deleteSync\(key: string\)<a name="zh-cn_topic_0000001117163542_section1360034110271"></a> 1179 1180从此对象中删除名为给定key的存储。 1181 1182此方法为同步方法。 1183 1184**参数:** 1185 1186<a name="zh-cn_topic_0000001117163542_table0601144116279"></a> 1187<table><thead align="left"><tr id="zh-cn_topic_0000001117163542_row1760118411270"><th class="cellrowborder" valign="top" width="14.82%" id="mcps1.1.5.1.1"><p id="zh-cn_topic_0000001117163542_p560110414271"><a name="zh-cn_topic_0000001117163542_p560110414271"></a><a name="zh-cn_topic_0000001117163542_p560110414271"></a>参数名</p> 1188</th> 1189<th class="cellrowborder" valign="top" width="14.729999999999999%" id="mcps1.1.5.1.2"><p id="zh-cn_topic_0000001117163542_p12602174114274"><a name="zh-cn_topic_0000001117163542_p12602174114274"></a><a name="zh-cn_topic_0000001117163542_p12602174114274"></a>类型</p> 1190</th> 1191<th class="cellrowborder" valign="top" width="9.16%" id="mcps1.1.5.1.3"><p id="zh-cn_topic_0000001117163542_p160224117275"><a name="zh-cn_topic_0000001117163542_p160224117275"></a><a name="zh-cn_topic_0000001117163542_p160224117275"></a>必填</p> 1192</th> 1193<th class="cellrowborder" valign="top" width="61.29%" id="mcps1.1.5.1.4"><p id="zh-cn_topic_0000001117163542_p060234114274"><a name="zh-cn_topic_0000001117163542_p060234114274"></a><a name="zh-cn_topic_0000001117163542_p060234114274"></a>说明</p> 1194</th> 1195</tr> 1196</thead> 1197<tbody><tr id="zh-cn_topic_0000001117163542_row560218415279"><td class="cellrowborder" valign="top" width="14.82%" headers="mcps1.1.5.1.1 "><p id="zh-cn_topic_0000001117163542_p1660204119276"><a name="zh-cn_topic_0000001117163542_p1660204119276"></a><a name="zh-cn_topic_0000001117163542_p1660204119276"></a>key</p> 1198</td> 1199<td class="cellrowborder" valign="top" width="14.729999999999999%" headers="mcps1.1.5.1.2 "><p id="zh-cn_topic_0000001117163542_p56021341112718"><a name="zh-cn_topic_0000001117163542_p56021341112718"></a><a name="zh-cn_topic_0000001117163542_p56021341112718"></a>string</p> 1200</td> 1201<td class="cellrowborder" valign="top" width="9.16%" headers="mcps1.1.5.1.3 "><p id="zh-cn_topic_0000001117163542_p9602104182714"><a name="zh-cn_topic_0000001117163542_p9602104182714"></a><a name="zh-cn_topic_0000001117163542_p9602104182714"></a>是</p> 1202</td> 1203<td class="cellrowborder" valign="top" width="61.29%" headers="mcps1.1.5.1.4 "><p id="zh-cn_topic_0000001117163542_p1260394118270"><a name="zh-cn_topic_0000001117163542_p1260394118270"></a><a name="zh-cn_topic_0000001117163542_p1260394118270"></a>要获取的存储key名称。它不能为空。</p> 1204</td> 1205</tr> 1206</tbody> 1207</table> 1208 1209**返回值:** 1210 1211<a name="zh-cn_topic_0000001117163542_table156033413277"></a> 1212<table><thead align="left"><tr id="zh-cn_topic_0000001117163542_row96033415277"><th class="cellrowborder" valign="top" width="17.01%" id="mcps1.1.3.1.1"><p id="zh-cn_topic_0000001117163542_p660317411279"><a name="zh-cn_topic_0000001117163542_p660317411279"></a><a name="zh-cn_topic_0000001117163542_p660317411279"></a>类型</p> 1213</th> 1214<th class="cellrowborder" valign="top" width="82.99%" id="mcps1.1.3.1.2"><p id="zh-cn_topic_0000001117163542_p14603194118271"><a name="zh-cn_topic_0000001117163542_p14603194118271"></a><a name="zh-cn_topic_0000001117163542_p14603194118271"></a>说明</p> 1215</th> 1216</tr> 1217</thead> 1218<tbody><tr id="zh-cn_topic_0000001117163542_row176041541202715"><td class="cellrowborder" valign="top" width="17.01%" headers="mcps1.1.3.1.1 "><p id="zh-cn_topic_0000001117163542_p4604154114274"><a name="zh-cn_topic_0000001117163542_p4604154114274"></a><a name="zh-cn_topic_0000001117163542_p4604154114274"></a>void</p> 1219</td> 1220<td class="cellrowborder" valign="top" width="82.99%" headers="mcps1.1.3.1.2 "><p id="zh-cn_topic_0000001117163542_p7604941142719"><a name="zh-cn_topic_0000001117163542_p7604941142719"></a><a name="zh-cn_topic_0000001117163542_p7604941142719"></a>无</p> 1221</td> 1222</tr> 1223</tbody> 1224</table> 1225 1226**示例:** 1227 1228``` 1229store.deleteSync(key); 1230``` 1231 1232## delete\(key: string, callback: AsyncCallback<void\>\)<a name="zh-cn_topic_0000001117163542_section1960515413272"></a> 1233 1234从此对象中删除名为给定key的存储。 1235 1236此方法为异步方法。 1237 1238**参数:** 1239 1240<a name="zh-cn_topic_0000001117163542_table16065416278"></a> 1241<table><thead align="left"><tr id="zh-cn_topic_0000001117163542_row86062416270"><th class="cellrowborder" valign="top" width="14.451487079473427%" id="mcps1.1.5.1.1"><p id="zh-cn_topic_0000001117163542_p260704122716"><a name="zh-cn_topic_0000001117163542_p260704122716"></a><a name="zh-cn_topic_0000001117163542_p260704122716"></a>参数名</p> 1242</th> 1243<th class="cellrowborder" valign="top" width="18.95660653339834%" id="mcps1.1.5.1.2"><p id="zh-cn_topic_0000001117163542_p17607241192711"><a name="zh-cn_topic_0000001117163542_p17607241192711"></a><a name="zh-cn_topic_0000001117163542_p17607241192711"></a>类型</p> 1244</th> 1245<th class="cellrowborder" valign="top" width="6.825938566552901%" id="mcps1.1.5.1.3"><p id="zh-cn_topic_0000001117163542_p11607194162719"><a name="zh-cn_topic_0000001117163542_p11607194162719"></a><a name="zh-cn_topic_0000001117163542_p11607194162719"></a>必填</p> 1246</th> 1247<th class="cellrowborder" valign="top" width="59.76596782057533%" id="mcps1.1.5.1.4"><p id="zh-cn_topic_0000001117163542_p1607441172716"><a name="zh-cn_topic_0000001117163542_p1607441172716"></a><a name="zh-cn_topic_0000001117163542_p1607441172716"></a>说明</p> 1248</th> 1249</tr> 1250</thead> 1251<tbody><tr id="zh-cn_topic_0000001117163542_row760774112719"><td class="cellrowborder" valign="top" width="14.451487079473427%" headers="mcps1.1.5.1.1 "><p id="zh-cn_topic_0000001117163542_p14607541182716"><a name="zh-cn_topic_0000001117163542_p14607541182716"></a><a name="zh-cn_topic_0000001117163542_p14607541182716"></a>key</p> 1252</td> 1253<td class="cellrowborder" valign="top" width="18.95660653339834%" headers="mcps1.1.5.1.2 "><p id="zh-cn_topic_0000001117163542_p1560864112717"><a name="zh-cn_topic_0000001117163542_p1560864112717"></a><a name="zh-cn_topic_0000001117163542_p1560864112717"></a>string</p> 1254</td> 1255<td class="cellrowborder" valign="top" width="6.825938566552901%" headers="mcps1.1.5.1.3 "><p id="zh-cn_topic_0000001117163542_p13608134192710"><a name="zh-cn_topic_0000001117163542_p13608134192710"></a><a name="zh-cn_topic_0000001117163542_p13608134192710"></a>是</p> 1256</td> 1257<td class="cellrowborder" valign="top" width="59.76596782057533%" headers="mcps1.1.5.1.4 "><p id="zh-cn_topic_0000001117163542_p156083412274"><a name="zh-cn_topic_0000001117163542_p156083412274"></a><a name="zh-cn_topic_0000001117163542_p156083412274"></a>要获取的存储key名称。它不能为空。</p> 1258</td> 1259</tr> 1260<tr id="zh-cn_topic_0000001117163542_row1160874110276"><td class="cellrowborder" valign="top" width="14.451487079473427%" headers="mcps1.1.5.1.1 "><p id="zh-cn_topic_0000001117163542_p19608164120277"><a name="zh-cn_topic_0000001117163542_p19608164120277"></a><a name="zh-cn_topic_0000001117163542_p19608164120277"></a>callback</p> 1261</td> 1262<td class="cellrowborder" valign="top" width="18.95660653339834%" headers="mcps1.1.5.1.2 "><p id="zh-cn_topic_0000001117163542_p20608114162717"><a name="zh-cn_topic_0000001117163542_p20608114162717"></a><a name="zh-cn_topic_0000001117163542_p20608114162717"></a>AsyncCallback<void></p> 1263</td> 1264<td class="cellrowborder" valign="top" width="6.825938566552901%" headers="mcps1.1.5.1.3 "><p id="zh-cn_topic_0000001117163542_p1660884118272"><a name="zh-cn_topic_0000001117163542_p1660884118272"></a><a name="zh-cn_topic_0000001117163542_p1660884118272"></a>是</p> 1265</td> 1266<td class="cellrowborder" valign="top" width="59.76596782057533%" headers="mcps1.1.5.1.4 "><p id="zh-cn_topic_0000001117163542_p060804115270"><a name="zh-cn_topic_0000001117163542_p060804115270"></a><a name="zh-cn_topic_0000001117163542_p060804115270"></a>回调函数。</p> 1267</td> 1268</tr> 1269</tbody> 1270</table> 1271 1272**返回值:** 1273 1274<a name="zh-cn_topic_0000001117163542_table8609104192715"></a> 1275<table><thead align="left"><tr id="zh-cn_topic_0000001117163542_row106094412279"><th class="cellrowborder" valign="top" width="17.01%" id="mcps1.1.3.1.1"><p id="zh-cn_topic_0000001117163542_p260917416271"><a name="zh-cn_topic_0000001117163542_p260917416271"></a><a name="zh-cn_topic_0000001117163542_p260917416271"></a>类型</p> 1276</th> 1277<th class="cellrowborder" valign="top" width="82.99%" id="mcps1.1.3.1.2"><p id="zh-cn_topic_0000001117163542_p660912415279"><a name="zh-cn_topic_0000001117163542_p660912415279"></a><a name="zh-cn_topic_0000001117163542_p660912415279"></a>说明</p> 1278</th> 1279</tr> 1280</thead> 1281<tbody><tr id="zh-cn_topic_0000001117163542_row061044192715"><td class="cellrowborder" valign="top" width="17.01%" headers="mcps1.1.3.1.1 "><p id="zh-cn_topic_0000001117163542_p11610241122714"><a name="zh-cn_topic_0000001117163542_p11610241122714"></a><a name="zh-cn_topic_0000001117163542_p11610241122714"></a>void</p> 1282</td> 1283<td class="cellrowborder" valign="top" width="82.99%" headers="mcps1.1.3.1.2 "><p id="zh-cn_topic_0000001117163542_p1610124110277"><a name="zh-cn_topic_0000001117163542_p1610124110277"></a><a name="zh-cn_topic_0000001117163542_p1610124110277"></a>无</p> 1284</td> 1285</tr> 1286</tbody> 1287</table> 1288 1289**示例:** 1290 1291``` 1292store.delete(key, function(err, data) { 1293}); 1294``` 1295 1296## delete\(key: string\)<a name="zh-cn_topic_0000001117163542_section36125414279"></a> 1297 1298从此对象中删除名为给定key的存储。 1299 1300此方法为异步方法。 1301 1302**参数:** 1303 1304<a name="zh-cn_topic_0000001117163542_table1761224113272"></a> 1305<table><thead align="left"><tr id="zh-cn_topic_0000001117163542_row3613341182713"><th class="cellrowborder" valign="top" width="14.451487079473427%" id="mcps1.1.5.1.1"><p id="zh-cn_topic_0000001117163542_p16131241182716"><a name="zh-cn_topic_0000001117163542_p16131241182716"></a><a name="zh-cn_topic_0000001117163542_p16131241182716"></a>参数名</p> 1306</th> 1307<th class="cellrowborder" valign="top" width="18.95660653339834%" id="mcps1.1.5.1.2"><p id="zh-cn_topic_0000001117163542_p10613241192711"><a name="zh-cn_topic_0000001117163542_p10613241192711"></a><a name="zh-cn_topic_0000001117163542_p10613241192711"></a>类型</p> 1308</th> 1309<th class="cellrowborder" valign="top" width="6.825938566552901%" id="mcps1.1.5.1.3"><p id="zh-cn_topic_0000001117163542_p7614541142718"><a name="zh-cn_topic_0000001117163542_p7614541142718"></a><a name="zh-cn_topic_0000001117163542_p7614541142718"></a>必填</p> 1310</th> 1311<th class="cellrowborder" valign="top" width="59.76596782057533%" id="mcps1.1.5.1.4"><p id="zh-cn_topic_0000001117163542_p1961416411279"><a name="zh-cn_topic_0000001117163542_p1961416411279"></a><a name="zh-cn_topic_0000001117163542_p1961416411279"></a>说明</p> 1312</th> 1313</tr> 1314</thead> 1315<tbody><tr id="zh-cn_topic_0000001117163542_row161424110272"><td class="cellrowborder" valign="top" width="14.451487079473427%" headers="mcps1.1.5.1.1 "><p id="zh-cn_topic_0000001117163542_p10614144152720"><a name="zh-cn_topic_0000001117163542_p10614144152720"></a><a name="zh-cn_topic_0000001117163542_p10614144152720"></a>key</p> 1316</td> 1317<td class="cellrowborder" valign="top" width="18.95660653339834%" headers="mcps1.1.5.1.2 "><p id="zh-cn_topic_0000001117163542_p76141341182712"><a name="zh-cn_topic_0000001117163542_p76141341182712"></a><a name="zh-cn_topic_0000001117163542_p76141341182712"></a>string</p> 1318</td> 1319<td class="cellrowborder" valign="top" width="6.825938566552901%" headers="mcps1.1.5.1.3 "><p id="zh-cn_topic_0000001117163542_p16145416275"><a name="zh-cn_topic_0000001117163542_p16145416275"></a><a name="zh-cn_topic_0000001117163542_p16145416275"></a>是</p> 1320</td> 1321<td class="cellrowborder" valign="top" width="59.76596782057533%" headers="mcps1.1.5.1.4 "><p id="zh-cn_topic_0000001117163542_p1961464114278"><a name="zh-cn_topic_0000001117163542_p1961464114278"></a><a name="zh-cn_topic_0000001117163542_p1961464114278"></a>要获取的存储key名称。它不能为空。</p> 1322</td> 1323</tr> 1324</tbody> 1325</table> 1326 1327**返回值:** 1328 1329<a name="zh-cn_topic_0000001117163542_table196151841182710"></a> 1330<table><thead align="left"><tr id="zh-cn_topic_0000001117163542_row7615124182719"><th class="cellrowborder" valign="top" width="17.01%" id="mcps1.1.3.1.1"><p id="zh-cn_topic_0000001117163542_p1561534182710"><a name="zh-cn_topic_0000001117163542_p1561534182710"></a><a name="zh-cn_topic_0000001117163542_p1561534182710"></a>类型</p> 1331</th> 1332<th class="cellrowborder" valign="top" width="82.99%" id="mcps1.1.3.1.2"><p id="zh-cn_topic_0000001117163542_p16615154111277"><a name="zh-cn_topic_0000001117163542_p16615154111277"></a><a name="zh-cn_topic_0000001117163542_p16615154111277"></a>说明</p> 1333</th> 1334</tr> 1335</thead> 1336<tbody><tr id="zh-cn_topic_0000001117163542_row461674113277"><td class="cellrowborder" valign="top" width="17.01%" headers="mcps1.1.3.1.1 "><p id="zh-cn_topic_0000001117163542_p8999525989"><a name="zh-cn_topic_0000001117163542_p8999525989"></a><a name="zh-cn_topic_0000001117163542_p8999525989"></a>Promise<void></p> 1337</td> 1338<td class="cellrowborder" valign="top" width="82.99%" headers="mcps1.1.3.1.2 "><p id="zh-cn_topic_0000001117163542_p09991256820"><a name="zh-cn_topic_0000001117163542_p09991256820"></a><a name="zh-cn_topic_0000001117163542_p09991256820"></a>Promise实例,用于异步处理。</p> 1339</td> 1340</tr> 1341</tbody> 1342</table> 1343 1344**示例:** 1345 1346``` 1347const promise = store.delete(key); 1348promise.then((data) => { 1349 }).catch((err) => { 1350}); 1351``` 1352 1353## flushSync\(\)<a name="zh-cn_topic_0000001117163542_section1593555103112"></a> 1354 1355将当前storage对象中的修改保存到当前的storage,并同步存储到文件中。 1356 1357此方法为同步方法。 1358 1359**参数:** 1360 1361<a name="zh-cn_topic_0000001117163542_table1493675113313"></a> 1362<table><thead align="left"><tr id="zh-cn_topic_0000001117163542_row4936451113115"><th class="cellrowborder" valign="top" width="14.82%" id="mcps1.1.5.1.1"><p id="zh-cn_topic_0000001117163542_p2936205143120"><a name="zh-cn_topic_0000001117163542_p2936205143120"></a><a name="zh-cn_topic_0000001117163542_p2936205143120"></a>参数名</p> 1363</th> 1364<th class="cellrowborder" valign="top" width="14.729999999999999%" id="mcps1.1.5.1.2"><p id="zh-cn_topic_0000001117163542_p29372514313"><a name="zh-cn_topic_0000001117163542_p29372514313"></a><a name="zh-cn_topic_0000001117163542_p29372514313"></a>类型</p> 1365</th> 1366<th class="cellrowborder" valign="top" width="9.16%" id="mcps1.1.5.1.3"><p id="zh-cn_topic_0000001117163542_p19937135118318"><a name="zh-cn_topic_0000001117163542_p19937135118318"></a><a name="zh-cn_topic_0000001117163542_p19937135118318"></a>必填</p> 1367</th> 1368<th class="cellrowborder" valign="top" width="61.29%" id="mcps1.1.5.1.4"><p id="zh-cn_topic_0000001117163542_p179371451193118"><a name="zh-cn_topic_0000001117163542_p179371451193118"></a><a name="zh-cn_topic_0000001117163542_p179371451193118"></a>说明</p> 1369</th> 1370</tr> 1371</thead> 1372<tbody><tr id="zh-cn_topic_0000001117163542_row209371951163114"><td class="cellrowborder" valign="top" width="14.82%" headers="mcps1.1.5.1.1 "><p id="zh-cn_topic_0000001117163542_p561845563915"><a name="zh-cn_topic_0000001117163542_p561845563915"></a><a name="zh-cn_topic_0000001117163542_p561845563915"></a>无</p> 1373</td> 1374<td class="cellrowborder" valign="top" width="14.729999999999999%" headers="mcps1.1.5.1.2 "><p id="zh-cn_topic_0000001117163542_p1859616074011"><a name="zh-cn_topic_0000001117163542_p1859616074011"></a><a name="zh-cn_topic_0000001117163542_p1859616074011"></a>无</p> 1375</td> 1376<td class="cellrowborder" valign="top" width="9.16%" headers="mcps1.1.5.1.3 "><p id="zh-cn_topic_0000001117163542_p129383519316"><a name="zh-cn_topic_0000001117163542_p129383519316"></a><a name="zh-cn_topic_0000001117163542_p129383519316"></a>无</p> 1377</td> 1378<td class="cellrowborder" valign="top" width="61.29%" headers="mcps1.1.5.1.4 "><p id="zh-cn_topic_0000001117163542_p13938125118319"><a name="zh-cn_topic_0000001117163542_p13938125118319"></a><a name="zh-cn_topic_0000001117163542_p13938125118319"></a>无</p> 1379</td> 1380</tr> 1381</tbody> 1382</table> 1383 1384**返回值:** 1385 1386<a name="zh-cn_topic_0000001117163542_table20938175115319"></a> 1387<table><thead align="left"><tr id="zh-cn_topic_0000001117163542_row493918511318"><th class="cellrowborder" valign="top" width="17.01%" id="mcps1.1.3.1.1"><p id="zh-cn_topic_0000001117163542_p12939145114318"><a name="zh-cn_topic_0000001117163542_p12939145114318"></a><a name="zh-cn_topic_0000001117163542_p12939145114318"></a>类型</p> 1388</th> 1389<th class="cellrowborder" valign="top" width="82.99%" id="mcps1.1.3.1.2"><p id="zh-cn_topic_0000001117163542_p193975173112"><a name="zh-cn_topic_0000001117163542_p193975173112"></a><a name="zh-cn_topic_0000001117163542_p193975173112"></a>说明</p> 1390</th> 1391</tr> 1392</thead> 1393<tbody><tr id="zh-cn_topic_0000001117163542_row10939135116313"><td class="cellrowborder" valign="top" width="17.01%" headers="mcps1.1.3.1.1 "><p id="zh-cn_topic_0000001117163542_p1394095153116"><a name="zh-cn_topic_0000001117163542_p1394095153116"></a><a name="zh-cn_topic_0000001117163542_p1394095153116"></a>void</p> 1394</td> 1395<td class="cellrowborder" valign="top" width="82.99%" headers="mcps1.1.3.1.2 "><p id="zh-cn_topic_0000001117163542_p99401451123115"><a name="zh-cn_topic_0000001117163542_p99401451123115"></a><a name="zh-cn_topic_0000001117163542_p99401451123115"></a>无</p> 1396</td> 1397</tr> 1398</tbody> 1399</table> 1400 1401**示例:** 1402 1403``` 1404store.flushSync(); 1405``` 1406 1407## flush\(callback: AsyncCallback<void\>\)<a name="zh-cn_topic_0000001117163542_section1994165173117"></a> 1408 1409将当前storage对象中的修改保存到当前的storage,并异步存储到文件中。 1410 1411此方法为异步方法。 1412 1413**参数:** 1414 1415<a name="zh-cn_topic_0000001117163542_table15942115183115"></a> 1416<table><thead align="left"><tr id="zh-cn_topic_0000001117163542_row109421151173115"><th class="cellrowborder" valign="top" width="14.451487079473427%" id="mcps1.1.5.1.1"><p id="zh-cn_topic_0000001117163542_p13942251143112"><a name="zh-cn_topic_0000001117163542_p13942251143112"></a><a name="zh-cn_topic_0000001117163542_p13942251143112"></a>参数名</p> 1417</th> 1418<th class="cellrowborder" valign="top" width="18.95660653339834%" id="mcps1.1.5.1.2"><p id="zh-cn_topic_0000001117163542_p9943351133114"><a name="zh-cn_topic_0000001117163542_p9943351133114"></a><a name="zh-cn_topic_0000001117163542_p9943351133114"></a>类型</p> 1419</th> 1420<th class="cellrowborder" valign="top" width="6.825938566552901%" id="mcps1.1.5.1.3"><p id="zh-cn_topic_0000001117163542_p1694355143116"><a name="zh-cn_topic_0000001117163542_p1694355143116"></a><a name="zh-cn_topic_0000001117163542_p1694355143116"></a>必填</p> 1421</th> 1422<th class="cellrowborder" valign="top" width="59.76596782057533%" id="mcps1.1.5.1.4"><p id="zh-cn_topic_0000001117163542_p149431451133110"><a name="zh-cn_topic_0000001117163542_p149431451133110"></a><a name="zh-cn_topic_0000001117163542_p149431451133110"></a>说明</p> 1423</th> 1424</tr> 1425</thead> 1426<tbody><tr id="zh-cn_topic_0000001117163542_row59444519317"><td class="cellrowborder" valign="top" width="14.451487079473427%" headers="mcps1.1.5.1.1 "><p id="zh-cn_topic_0000001117163542_p7944195119316"><a name="zh-cn_topic_0000001117163542_p7944195119316"></a><a name="zh-cn_topic_0000001117163542_p7944195119316"></a>callback</p> 1427</td> 1428<td class="cellrowborder" valign="top" width="18.95660653339834%" headers="mcps1.1.5.1.2 "><p id="zh-cn_topic_0000001117163542_p494435110315"><a name="zh-cn_topic_0000001117163542_p494435110315"></a><a name="zh-cn_topic_0000001117163542_p494435110315"></a>AsyncCallback<void></p> 1429</td> 1430<td class="cellrowborder" valign="top" width="6.825938566552901%" headers="mcps1.1.5.1.3 "><p id="zh-cn_topic_0000001117163542_p15945651123113"><a name="zh-cn_topic_0000001117163542_p15945651123113"></a><a name="zh-cn_topic_0000001117163542_p15945651123113"></a>是</p> 1431</td> 1432<td class="cellrowborder" valign="top" width="59.76596782057533%" headers="mcps1.1.5.1.4 "><p id="zh-cn_topic_0000001117163542_p394505193117"><a name="zh-cn_topic_0000001117163542_p394505193117"></a><a name="zh-cn_topic_0000001117163542_p394505193117"></a>回调函数。</p> 1433</td> 1434</tr> 1435</tbody> 1436</table> 1437 1438**返回值:** 1439 1440<a name="zh-cn_topic_0000001117163542_table109451651113119"></a> 1441<table><thead align="left"><tr id="zh-cn_topic_0000001117163542_row14946451103117"><th class="cellrowborder" valign="top" width="17.01%" id="mcps1.1.3.1.1"><p id="zh-cn_topic_0000001117163542_p12946551123115"><a name="zh-cn_topic_0000001117163542_p12946551123115"></a><a name="zh-cn_topic_0000001117163542_p12946551123115"></a>类型</p> 1442</th> 1443<th class="cellrowborder" valign="top" width="82.99%" id="mcps1.1.3.1.2"><p id="zh-cn_topic_0000001117163542_p2094685116313"><a name="zh-cn_topic_0000001117163542_p2094685116313"></a><a name="zh-cn_topic_0000001117163542_p2094685116313"></a>说明</p> 1444</th> 1445</tr> 1446</thead> 1447<tbody><tr id="zh-cn_topic_0000001117163542_row59461151163116"><td class="cellrowborder" valign="top" width="17.01%" headers="mcps1.1.3.1.1 "><p id="zh-cn_topic_0000001117163542_p394695110317"><a name="zh-cn_topic_0000001117163542_p394695110317"></a><a name="zh-cn_topic_0000001117163542_p394695110317"></a>void</p> 1448</td> 1449<td class="cellrowborder" valign="top" width="82.99%" headers="mcps1.1.3.1.2 "><p id="zh-cn_topic_0000001117163542_p09478516313"><a name="zh-cn_topic_0000001117163542_p09478516313"></a><a name="zh-cn_topic_0000001117163542_p09478516313"></a>无</p> 1450</td> 1451</tr> 1452</tbody> 1453</table> 1454 1455**示例:** 1456 1457``` 1458store.flush(function(err, data) { 1459}); 1460``` 1461 1462## flush\(\)<a name="zh-cn_topic_0000001117163542_section169491651163113"></a> 1463 1464将当前storage对象中的修改保存到当前的storage,并异步存储到文件中。 1465 1466此方法为异步方法。 1467 1468**参数:** 1469 1470<a name="zh-cn_topic_0000001117163542_table1394975113117"></a> 1471<table><thead align="left"><tr id="zh-cn_topic_0000001117163542_row159501951183113"><th class="cellrowborder" valign="top" width="14.451487079473427%" id="mcps1.1.5.1.1"><p id="zh-cn_topic_0000001117163542_p595075113112"><a name="zh-cn_topic_0000001117163542_p595075113112"></a><a name="zh-cn_topic_0000001117163542_p595075113112"></a>参数名</p> 1472</th> 1473<th class="cellrowborder" valign="top" width="18.95660653339834%" id="mcps1.1.5.1.2"><p id="zh-cn_topic_0000001117163542_p695085111316"><a name="zh-cn_topic_0000001117163542_p695085111316"></a><a name="zh-cn_topic_0000001117163542_p695085111316"></a>类型</p> 1474</th> 1475<th class="cellrowborder" valign="top" width="6.825938566552901%" id="mcps1.1.5.1.3"><p id="zh-cn_topic_0000001117163542_p4950165153113"><a name="zh-cn_topic_0000001117163542_p4950165153113"></a><a name="zh-cn_topic_0000001117163542_p4950165153113"></a>必填</p> 1476</th> 1477<th class="cellrowborder" valign="top" width="59.76596782057533%" id="mcps1.1.5.1.4"><p id="zh-cn_topic_0000001117163542_p195075112313"><a name="zh-cn_topic_0000001117163542_p195075112313"></a><a name="zh-cn_topic_0000001117163542_p195075112313"></a>说明</p> 1478</th> 1479</tr> 1480</thead> 1481<tbody><tr id="zh-cn_topic_0000001117163542_row17951195163119"><td class="cellrowborder" valign="top" width="14.451487079473427%" headers="mcps1.1.5.1.1 "><p id="zh-cn_topic_0000001117163542_p179511251193116"><a name="zh-cn_topic_0000001117163542_p179511251193116"></a><a name="zh-cn_topic_0000001117163542_p179511251193116"></a>无</p> 1482</td> 1483<td class="cellrowborder" valign="top" width="18.95660653339834%" headers="mcps1.1.5.1.2 "><p id="zh-cn_topic_0000001117163542_p17951551183118"><a name="zh-cn_topic_0000001117163542_p17951551183118"></a><a name="zh-cn_topic_0000001117163542_p17951551183118"></a>无</p> 1484</td> 1485<td class="cellrowborder" valign="top" width="6.825938566552901%" headers="mcps1.1.5.1.3 "><p id="zh-cn_topic_0000001117163542_p129526519318"><a name="zh-cn_topic_0000001117163542_p129526519318"></a><a name="zh-cn_topic_0000001117163542_p129526519318"></a>无</p> 1486</td> 1487<td class="cellrowborder" valign="top" width="59.76596782057533%" headers="mcps1.1.5.1.4 "><p id="zh-cn_topic_0000001117163542_p595245120316"><a name="zh-cn_topic_0000001117163542_p595245120316"></a><a name="zh-cn_topic_0000001117163542_p595245120316"></a>无</p> 1488</td> 1489</tr> 1490</tbody> 1491</table> 1492 1493**返回值:** 1494 1495<a name="zh-cn_topic_0000001117163542_table1795245183114"></a> 1496<table><thead align="left"><tr id="zh-cn_topic_0000001117163542_row1595215113117"><th class="cellrowborder" valign="top" width="17.01%" id="mcps1.1.3.1.1"><p id="zh-cn_topic_0000001117163542_p14952151103113"><a name="zh-cn_topic_0000001117163542_p14952151103113"></a><a name="zh-cn_topic_0000001117163542_p14952151103113"></a>类型</p> 1497</th> 1498<th class="cellrowborder" valign="top" width="82.99%" id="mcps1.1.3.1.2"><p id="zh-cn_topic_0000001117163542_p79531051103116"><a name="zh-cn_topic_0000001117163542_p79531051103116"></a><a name="zh-cn_topic_0000001117163542_p79531051103116"></a>说明</p> 1499</th> 1500</tr> 1501</thead> 1502<tbody><tr id="zh-cn_topic_0000001117163542_row495395113110"><td class="cellrowborder" valign="top" width="17.01%" headers="mcps1.1.3.1.1 "><p id="zh-cn_topic_0000001117163542_p15337433587"><a name="zh-cn_topic_0000001117163542_p15337433587"></a><a name="zh-cn_topic_0000001117163542_p15337433587"></a>Promise<void></p> 1503</td> 1504<td class="cellrowborder" valign="top" width="82.99%" headers="mcps1.1.3.1.2 "><p id="zh-cn_topic_0000001117163542_p2337193319813"><a name="zh-cn_topic_0000001117163542_p2337193319813"></a><a name="zh-cn_topic_0000001117163542_p2337193319813"></a>Promise实例,用于异步处理。</p> 1505</td> 1506</tr> 1507</tbody> 1508</table> 1509 1510**示例:** 1511 1512``` 1513const promise = store.flush(); 1514promise.then((data) => { 1515 }).catch((err) => { 1516}); 1517``` 1518 1519## clearSync\(\)<a name="zh-cn_topic_0000001117163542_section890817195434"></a> 1520 1521清除此存储对象中的所有存储。 1522 1523此方法为同步方法。 1524 1525**参数:** 1526 1527<a name="zh-cn_topic_0000001117163542_table8908131915433"></a> 1528<table><thead align="left"><tr id="zh-cn_topic_0000001117163542_row290915193434"><th class="cellrowborder" valign="top" width="14.82%" id="mcps1.1.5.1.1"><p id="zh-cn_topic_0000001117163542_p79091619124316"><a name="zh-cn_topic_0000001117163542_p79091619124316"></a><a name="zh-cn_topic_0000001117163542_p79091619124316"></a>参数名</p> 1529</th> 1530<th class="cellrowborder" valign="top" width="14.729999999999999%" id="mcps1.1.5.1.2"><p id="zh-cn_topic_0000001117163542_p19092019184313"><a name="zh-cn_topic_0000001117163542_p19092019184313"></a><a name="zh-cn_topic_0000001117163542_p19092019184313"></a>类型</p> 1531</th> 1532<th class="cellrowborder" valign="top" width="9.16%" id="mcps1.1.5.1.3"><p id="zh-cn_topic_0000001117163542_p19909101964314"><a name="zh-cn_topic_0000001117163542_p19909101964314"></a><a name="zh-cn_topic_0000001117163542_p19909101964314"></a>必填</p> 1533</th> 1534<th class="cellrowborder" valign="top" width="61.29%" id="mcps1.1.5.1.4"><p id="zh-cn_topic_0000001117163542_p1991041954313"><a name="zh-cn_topic_0000001117163542_p1991041954313"></a><a name="zh-cn_topic_0000001117163542_p1991041954313"></a>说明</p> 1535</th> 1536</tr> 1537</thead> 1538<tbody><tr id="zh-cn_topic_0000001117163542_row10910171910431"><td class="cellrowborder" valign="top" width="14.82%" headers="mcps1.1.5.1.1 "><p id="zh-cn_topic_0000001117163542_p169101019114312"><a name="zh-cn_topic_0000001117163542_p169101019114312"></a><a name="zh-cn_topic_0000001117163542_p169101019114312"></a>无</p> 1539</td> 1540<td class="cellrowborder" valign="top" width="14.729999999999999%" headers="mcps1.1.5.1.2 "><p id="zh-cn_topic_0000001117163542_p9910319194315"><a name="zh-cn_topic_0000001117163542_p9910319194315"></a><a name="zh-cn_topic_0000001117163542_p9910319194315"></a>无</p> 1541</td> 1542<td class="cellrowborder" valign="top" width="9.16%" headers="mcps1.1.5.1.3 "><p id="zh-cn_topic_0000001117163542_p7910419174310"><a name="zh-cn_topic_0000001117163542_p7910419174310"></a><a name="zh-cn_topic_0000001117163542_p7910419174310"></a>无</p> 1543</td> 1544<td class="cellrowborder" valign="top" width="61.29%" headers="mcps1.1.5.1.4 "><p id="zh-cn_topic_0000001117163542_p1910141994316"><a name="zh-cn_topic_0000001117163542_p1910141994316"></a><a name="zh-cn_topic_0000001117163542_p1910141994316"></a>无</p> 1545</td> 1546</tr> 1547</tbody> 1548</table> 1549 1550**返回值:** 1551 1552<a name="zh-cn_topic_0000001117163542_table17911131904316"></a> 1553<table><thead align="left"><tr id="zh-cn_topic_0000001117163542_row189110197437"><th class="cellrowborder" valign="top" width="17.01%" id="mcps1.1.3.1.1"><p id="zh-cn_topic_0000001117163542_p7911819184312"><a name="zh-cn_topic_0000001117163542_p7911819184312"></a><a name="zh-cn_topic_0000001117163542_p7911819184312"></a>类型</p> 1554</th> 1555<th class="cellrowborder" valign="top" width="82.99%" id="mcps1.1.3.1.2"><p id="zh-cn_topic_0000001117163542_p59111419144310"><a name="zh-cn_topic_0000001117163542_p59111419144310"></a><a name="zh-cn_topic_0000001117163542_p59111419144310"></a>说明</p> 1556</th> 1557</tr> 1558</thead> 1559<tbody><tr id="zh-cn_topic_0000001117163542_row18912171954318"><td class="cellrowborder" valign="top" width="17.01%" headers="mcps1.1.3.1.1 "><p id="zh-cn_topic_0000001117163542_p491213191431"><a name="zh-cn_topic_0000001117163542_p491213191431"></a><a name="zh-cn_topic_0000001117163542_p491213191431"></a>void</p> 1560</td> 1561<td class="cellrowborder" valign="top" width="82.99%" headers="mcps1.1.3.1.2 "><p id="zh-cn_topic_0000001117163542_p59124198434"><a name="zh-cn_topic_0000001117163542_p59124198434"></a><a name="zh-cn_topic_0000001117163542_p59124198434"></a>无</p> 1562</td> 1563</tr> 1564</tbody> 1565</table> 1566 1567**示例:** 1568 1569``` 1570store.clearSync(); 1571``` 1572 1573## clear\(callback: AsyncCallback<void\>\)<a name="zh-cn_topic_0000001117163542_section291391994316"></a> 1574 1575清除此存储对象中的所有存储。 1576 1577此方法为异步方法。 1578 1579**参数:** 1580 1581<a name="zh-cn_topic_0000001117163542_table139131919154315"></a> 1582<table><thead align="left"><tr id="zh-cn_topic_0000001117163542_row12914171916439"><th class="cellrowborder" valign="top" width="14.451487079473427%" id="mcps1.1.5.1.1"><p id="zh-cn_topic_0000001117163542_p209141519204311"><a name="zh-cn_topic_0000001117163542_p209141519204311"></a><a name="zh-cn_topic_0000001117163542_p209141519204311"></a>参数名</p> 1583</th> 1584<th class="cellrowborder" valign="top" width="18.95660653339834%" id="mcps1.1.5.1.2"><p id="zh-cn_topic_0000001117163542_p991418192433"><a name="zh-cn_topic_0000001117163542_p991418192433"></a><a name="zh-cn_topic_0000001117163542_p991418192433"></a>类型</p> 1585</th> 1586<th class="cellrowborder" valign="top" width="6.825938566552901%" id="mcps1.1.5.1.3"><p id="zh-cn_topic_0000001117163542_p11914101918437"><a name="zh-cn_topic_0000001117163542_p11914101918437"></a><a name="zh-cn_topic_0000001117163542_p11914101918437"></a>必填</p> 1587</th> 1588<th class="cellrowborder" valign="top" width="59.76596782057533%" id="mcps1.1.5.1.4"><p id="zh-cn_topic_0000001117163542_p1491512198430"><a name="zh-cn_topic_0000001117163542_p1491512198430"></a><a name="zh-cn_topic_0000001117163542_p1491512198430"></a>说明</p> 1589</th> 1590</tr> 1591</thead> 1592<tbody><tr id="zh-cn_topic_0000001117163542_row491551911431"><td class="cellrowborder" valign="top" width="14.451487079473427%" headers="mcps1.1.5.1.1 "><p id="zh-cn_topic_0000001117163542_p16915171914436"><a name="zh-cn_topic_0000001117163542_p16915171914436"></a><a name="zh-cn_topic_0000001117163542_p16915171914436"></a>callback</p> 1593</td> 1594<td class="cellrowborder" valign="top" width="18.95660653339834%" headers="mcps1.1.5.1.2 "><p id="zh-cn_topic_0000001117163542_p169157196434"><a name="zh-cn_topic_0000001117163542_p169157196434"></a><a name="zh-cn_topic_0000001117163542_p169157196434"></a>AsyncCallback<void></p> 1595</td> 1596<td class="cellrowborder" valign="top" width="6.825938566552901%" headers="mcps1.1.5.1.3 "><p id="zh-cn_topic_0000001117163542_p16915319174318"><a name="zh-cn_topic_0000001117163542_p16915319174318"></a><a name="zh-cn_topic_0000001117163542_p16915319174318"></a>是</p> 1597</td> 1598<td class="cellrowborder" valign="top" width="59.76596782057533%" headers="mcps1.1.5.1.4 "><p id="zh-cn_topic_0000001117163542_p491613199436"><a name="zh-cn_topic_0000001117163542_p491613199436"></a><a name="zh-cn_topic_0000001117163542_p491613199436"></a>回调函数。</p> 1599</td> 1600</tr> 1601</tbody> 1602</table> 1603 1604**返回值:** 1605 1606<a name="zh-cn_topic_0000001117163542_table79165196436"></a> 1607<table><thead align="left"><tr id="zh-cn_topic_0000001117163542_row79171119194314"><th class="cellrowborder" valign="top" width="17.01%" id="mcps1.1.3.1.1"><p id="zh-cn_topic_0000001117163542_p6917119144317"><a name="zh-cn_topic_0000001117163542_p6917119144317"></a><a name="zh-cn_topic_0000001117163542_p6917119144317"></a>类型</p> 1608</th> 1609<th class="cellrowborder" valign="top" width="82.99%" id="mcps1.1.3.1.2"><p id="zh-cn_topic_0000001117163542_p189171919184312"><a name="zh-cn_topic_0000001117163542_p189171919184312"></a><a name="zh-cn_topic_0000001117163542_p189171919184312"></a>说明</p> 1610</th> 1611</tr> 1612</thead> 1613<tbody><tr id="zh-cn_topic_0000001117163542_row29174199437"><td class="cellrowborder" valign="top" width="17.01%" headers="mcps1.1.3.1.1 "><p id="zh-cn_topic_0000001117163542_p8917171954317"><a name="zh-cn_topic_0000001117163542_p8917171954317"></a><a name="zh-cn_topic_0000001117163542_p8917171954317"></a>void</p> 1614</td> 1615<td class="cellrowborder" valign="top" width="82.99%" headers="mcps1.1.3.1.2 "><p id="zh-cn_topic_0000001117163542_p2917191910431"><a name="zh-cn_topic_0000001117163542_p2917191910431"></a><a name="zh-cn_topic_0000001117163542_p2917191910431"></a>无</p> 1616</td> 1617</tr> 1618</tbody> 1619</table> 1620 1621**示例:** 1622 1623``` 1624store.clear(function(err, data) { 1625}); 1626``` 1627 1628## clear\(\)<a name="zh-cn_topic_0000001117163542_section19192196432"></a> 1629 1630清除此存储对象中的所有存储。 1631 1632此方法为异步方法。 1633 1634**参数:** 1635 1636<a name="zh-cn_topic_0000001117163542_table13920619114319"></a> 1637<table><thead align="left"><tr id="zh-cn_topic_0000001117163542_row1092011934310"><th class="cellrowborder" valign="top" width="14.451487079473427%" id="mcps1.1.5.1.1"><p id="zh-cn_topic_0000001117163542_p79201719104316"><a name="zh-cn_topic_0000001117163542_p79201719104316"></a><a name="zh-cn_topic_0000001117163542_p79201719104316"></a>参数名</p> 1638</th> 1639<th class="cellrowborder" valign="top" width="18.95660653339834%" id="mcps1.1.5.1.2"><p id="zh-cn_topic_0000001117163542_p14921191954318"><a name="zh-cn_topic_0000001117163542_p14921191954318"></a><a name="zh-cn_topic_0000001117163542_p14921191954318"></a>类型</p> 1640</th> 1641<th class="cellrowborder" valign="top" width="6.825938566552901%" id="mcps1.1.5.1.3"><p id="zh-cn_topic_0000001117163542_p69211199438"><a name="zh-cn_topic_0000001117163542_p69211199438"></a><a name="zh-cn_topic_0000001117163542_p69211199438"></a>必填</p> 1642</th> 1643<th class="cellrowborder" valign="top" width="59.76596782057533%" id="mcps1.1.5.1.4"><p id="zh-cn_topic_0000001117163542_p15921181910436"><a name="zh-cn_topic_0000001117163542_p15921181910436"></a><a name="zh-cn_topic_0000001117163542_p15921181910436"></a>说明</p> 1644</th> 1645</tr> 1646</thead> 1647<tbody><tr id="zh-cn_topic_0000001117163542_row15921151913439"><td class="cellrowborder" valign="top" width="14.451487079473427%" headers="mcps1.1.5.1.1 "><p id="zh-cn_topic_0000001117163542_p1592191914432"><a name="zh-cn_topic_0000001117163542_p1592191914432"></a><a name="zh-cn_topic_0000001117163542_p1592191914432"></a>无</p> 1648</td> 1649<td class="cellrowborder" valign="top" width="18.95660653339834%" headers="mcps1.1.5.1.2 "><p id="zh-cn_topic_0000001117163542_p149211193439"><a name="zh-cn_topic_0000001117163542_p149211193439"></a><a name="zh-cn_topic_0000001117163542_p149211193439"></a>无</p> 1650</td> 1651<td class="cellrowborder" valign="top" width="6.825938566552901%" headers="mcps1.1.5.1.3 "><p id="zh-cn_topic_0000001117163542_p192111934310"><a name="zh-cn_topic_0000001117163542_p192111934310"></a><a name="zh-cn_topic_0000001117163542_p192111934310"></a>无</p> 1652</td> 1653<td class="cellrowborder" valign="top" width="59.76596782057533%" headers="mcps1.1.5.1.4 "><p id="zh-cn_topic_0000001117163542_p792261974313"><a name="zh-cn_topic_0000001117163542_p792261974313"></a><a name="zh-cn_topic_0000001117163542_p792261974313"></a>无</p> 1654</td> 1655</tr> 1656</tbody> 1657</table> 1658 1659**返回值:** 1660 1661<a name="zh-cn_topic_0000001117163542_table2092201916435"></a> 1662<table><thead align="left"><tr id="zh-cn_topic_0000001117163542_row1992221919433"><th class="cellrowborder" valign="top" width="17.01%" id="mcps1.1.3.1.1"><p id="zh-cn_topic_0000001117163542_p1192311197439"><a name="zh-cn_topic_0000001117163542_p1192311197439"></a><a name="zh-cn_topic_0000001117163542_p1192311197439"></a>类型</p> 1663</th> 1664<th class="cellrowborder" valign="top" width="82.99%" id="mcps1.1.3.1.2"><p id="zh-cn_topic_0000001117163542_p109231196438"><a name="zh-cn_topic_0000001117163542_p109231196438"></a><a name="zh-cn_topic_0000001117163542_p109231196438"></a>说明</p> 1665</th> 1666</tr> 1667</thead> 1668<tbody><tr id="zh-cn_topic_0000001117163542_row129231619134314"><td class="cellrowborder" valign="top" width="17.01%" headers="mcps1.1.3.1.1 "><p id="zh-cn_topic_0000001117163542_p6721740583"><a name="zh-cn_topic_0000001117163542_p6721740583"></a><a name="zh-cn_topic_0000001117163542_p6721740583"></a>Promise<void></p> 1669</td> 1670<td class="cellrowborder" valign="top" width="82.99%" headers="mcps1.1.3.1.2 "><p id="zh-cn_topic_0000001117163542_p1972740688"><a name="zh-cn_topic_0000001117163542_p1972740688"></a><a name="zh-cn_topic_0000001117163542_p1972740688"></a>Promise实例,用于异步处理。</p> 1671</td> 1672</tr> 1673</tbody> 1674</table> 1675 1676**示例:** 1677 1678``` 1679const promise = store.clear(); 1680promise.then((data) => { 1681 }).catch((err) => { 1682}); 1683``` 1684 1685## on\(type: 'change', callback: Callback<StorageObserver\>\)<a name="zh-cn_topic_0000001117163542_section19353521332"></a> 1686 1687监听者类需要实现StorageObserver接口,当数据发生改变时,监听者的 StorageObserver\#onChange会被回调。 1688 1689<a name="zh-cn_topic_0000001117163542_table1993675218315"></a> 1690<table><thead align="left"><tr id="zh-cn_topic_0000001117163542_row129362521838"><th class="cellrowborder" valign="top" width="24.060000000000002%" id="mcps1.1.4.1.1"><p id="zh-cn_topic_0000001117163542_p1193711521037"><a name="zh-cn_topic_0000001117163542_p1193711521037"></a><a name="zh-cn_topic_0000001117163542_p1193711521037"></a>参数名</p> 1691</th> 1692<th class="cellrowborder" valign="top" width="25.25%" id="mcps1.1.4.1.2"><p id="zh-cn_topic_0000001117163542_p79372521430"><a name="zh-cn_topic_0000001117163542_p79372521430"></a><a name="zh-cn_topic_0000001117163542_p79372521430"></a>类型</p> 1693</th> 1694<th class="cellrowborder" valign="top" width="50.690000000000005%" id="mcps1.1.4.1.3"><p id="zh-cn_topic_0000001117163542_p09376524315"><a name="zh-cn_topic_0000001117163542_p09376524315"></a><a name="zh-cn_topic_0000001117163542_p09376524315"></a>说明</p> 1695</th> 1696</tr> 1697</thead> 1698<tbody><tr id="zh-cn_topic_0000001117163542_row652511191284"><td class="cellrowborder" valign="top" width="24.060000000000002%" headers="mcps1.1.4.1.1 "><p id="zh-cn_topic_0000001117163542_p115269191082"><a name="zh-cn_topic_0000001117163542_p115269191082"></a><a name="zh-cn_topic_0000001117163542_p115269191082"></a>type</p> 1699</td> 1700<td class="cellrowborder" valign="top" width="25.25%" headers="mcps1.1.4.1.2 "><p id="zh-cn_topic_0000001117163542_p105268194810"><a name="zh-cn_topic_0000001117163542_p105268194810"></a><a name="zh-cn_topic_0000001117163542_p105268194810"></a>'change'</p> 1701</td> 1702<td class="cellrowborder" valign="top" width="50.690000000000005%" headers="mcps1.1.4.1.3 "><p id="zh-cn_topic_0000001117163542_p1852671914819"><a name="zh-cn_topic_0000001117163542_p1852671914819"></a><a name="zh-cn_topic_0000001117163542_p1852671914819"></a>事件类型,表示数据变更。</p> 1703</td> 1704</tr> 1705<tr id="zh-cn_topic_0000001117163542_row893735215313"><td class="cellrowborder" valign="top" width="24.060000000000002%" headers="mcps1.1.4.1.1 "><p id="zh-cn_topic_0000001117163542_p199389521136"><a name="zh-cn_topic_0000001117163542_p199389521136"></a><a name="zh-cn_topic_0000001117163542_p199389521136"></a>callback</p> 1706</td> 1707<td class="cellrowborder" valign="top" width="25.25%" headers="mcps1.1.4.1.2 "><p id="zh-cn_topic_0000001117163542_p89388521431"><a name="zh-cn_topic_0000001117163542_p89388521431"></a><a name="zh-cn_topic_0000001117163542_p89388521431"></a>Callback<StorageObserver></p> 1708</td> 1709<td class="cellrowborder" valign="top" width="50.690000000000005%" headers="mcps1.1.4.1.3 "><p id="zh-cn_topic_0000001117163542_p1938135211315"><a name="zh-cn_topic_0000001117163542_p1938135211315"></a><a name="zh-cn_topic_0000001117163542_p1938135211315"></a>当数据发生改变时,监听者的onChange会被回调。</p> 1710</td> 1711</tr> 1712</tbody> 1713</table> 1714 1715**示例:** 1716 1717``` 1718var observer = function (data) { 1719 console.info(data); 1720 }; 1721store.on('change', observer); 1722``` 1723 1724## off\(type: 'change', callback: Callback<StorageObserver\>\)<a name="zh-cn_topic_0000001117163542_section1194235213313"></a> 1725 1726监听者类需要实现StorageObserver接口,当不再进行数据监听时,使用此接口取消监听。 1727 1728<a name="zh-cn_topic_0000001117163542_table1094217520311"></a> 1729<table><thead align="left"><tr id="zh-cn_topic_0000001117163542_row89431552536"><th class="cellrowborder" valign="top" width="24.060000000000002%" id="mcps1.1.4.1.1"><p id="zh-cn_topic_0000001117163542_p1994325218317"><a name="zh-cn_topic_0000001117163542_p1994325218317"></a><a name="zh-cn_topic_0000001117163542_p1994325218317"></a>参数名</p> 1730</th> 1731<th class="cellrowborder" valign="top" width="25.25%" id="mcps1.1.4.1.2"><p id="zh-cn_topic_0000001117163542_p194315521133"><a name="zh-cn_topic_0000001117163542_p194315521133"></a><a name="zh-cn_topic_0000001117163542_p194315521133"></a>类型</p> 1732</th> 1733<th class="cellrowborder" valign="top" width="50.690000000000005%" id="mcps1.1.4.1.3"><p id="zh-cn_topic_0000001117163542_p3943185217317"><a name="zh-cn_topic_0000001117163542_p3943185217317"></a><a name="zh-cn_topic_0000001117163542_p3943185217317"></a>说明</p> 1734</th> 1735</tr> 1736</thead> 1737<tbody><tr id="zh-cn_topic_0000001117163542_row143551524181011"><td class="cellrowborder" valign="top" width="24.060000000000002%" headers="mcps1.1.4.1.1 "><p id="zh-cn_topic_0000001117163542_p6686113141017"><a name="zh-cn_topic_0000001117163542_p6686113141017"></a><a name="zh-cn_topic_0000001117163542_p6686113141017"></a>type</p> 1738</td> 1739<td class="cellrowborder" valign="top" width="25.25%" headers="mcps1.1.4.1.2 "><p id="zh-cn_topic_0000001117163542_p1468618310103"><a name="zh-cn_topic_0000001117163542_p1468618310103"></a><a name="zh-cn_topic_0000001117163542_p1468618310103"></a>'change'</p> 1740</td> 1741<td class="cellrowborder" valign="top" width="50.690000000000005%" headers="mcps1.1.4.1.3 "><p id="zh-cn_topic_0000001117163542_p2687193120109"><a name="zh-cn_topic_0000001117163542_p2687193120109"></a><a name="zh-cn_topic_0000001117163542_p2687193120109"></a>事件类型,表示数据变更。</p> 1742</td> 1743</tr> 1744<tr id="zh-cn_topic_0000001117163542_row594485217318"><td class="cellrowborder" valign="top" width="24.060000000000002%" headers="mcps1.1.4.1.1 "><p id="zh-cn_topic_0000001117163542_p1294410521536"><a name="zh-cn_topic_0000001117163542_p1294410521536"></a><a name="zh-cn_topic_0000001117163542_p1294410521536"></a>callback</p> 1745</td> 1746<td class="cellrowborder" valign="top" width="25.25%" headers="mcps1.1.4.1.2 "><p id="zh-cn_topic_0000001117163542_p18944152831"><a name="zh-cn_topic_0000001117163542_p18944152831"></a><a name="zh-cn_topic_0000001117163542_p18944152831"></a>Callback<StorageObserver></p> 1747</td> 1748<td class="cellrowborder" valign="top" width="50.690000000000005%" headers="mcps1.1.4.1.3 "><p id="zh-cn_topic_0000001117163542_p29445522317"><a name="zh-cn_topic_0000001117163542_p29445522317"></a><a name="zh-cn_topic_0000001117163542_p29445522317"></a>需要取消的回调对象实例</p> 1749</td> 1750</tr> 1751</tbody> 1752</table> 1753 1754**示例:** 1755 1756``` 1757var observer = function (data) { 1758 console.info(data); 1759 }; 1760store.off('change', observer); 1761``` 1762 1763## 事件<a name="zh-cn_topic_0000001117163542_section335774517218"></a> 1764 1765### change<a name="zh-cn_topic_0000001117163542_section1151314331741"></a> 1766 1767**表 1** 回调函数的参数说明(可选,如不涉及可删除) 1768 1769<a name="zh-cn_topic_0000001117163542_table851413312410"></a> 1770<table><thead align="left"><tr id="zh-cn_topic_0000001117163542_row951483314412"><th class="cellrowborder" valign="top" width="24.060000000000002%" id="mcps1.2.4.1.1"><p id="zh-cn_topic_0000001117163542_p451416338418"><a name="zh-cn_topic_0000001117163542_p451416338418"></a><a name="zh-cn_topic_0000001117163542_p451416338418"></a>参数名</p> 1771</th> 1772<th class="cellrowborder" valign="top" width="25.25%" id="mcps1.2.4.1.2"><p id="zh-cn_topic_0000001117163542_p1551416333415"><a name="zh-cn_topic_0000001117163542_p1551416333415"></a><a name="zh-cn_topic_0000001117163542_p1551416333415"></a>类型</p> 1773</th> 1774<th class="cellrowborder" valign="top" width="50.690000000000005%" id="mcps1.2.4.1.3"><p id="zh-cn_topic_0000001117163542_p145142338415"><a name="zh-cn_topic_0000001117163542_p145142338415"></a><a name="zh-cn_topic_0000001117163542_p145142338415"></a>说明</p> 1775</th> 1776</tr> 1777</thead> 1778<tbody><tr id="zh-cn_topic_0000001117163542_row18514113314414"><td class="cellrowborder" valign="top" width="24.060000000000002%" headers="mcps1.2.4.1.1 "><p id="zh-cn_topic_0000001117163542_p1651413331542"><a name="zh-cn_topic_0000001117163542_p1651413331542"></a><a name="zh-cn_topic_0000001117163542_p1651413331542"></a>observer</p> 1779</td> 1780<td class="cellrowborder" valign="top" width="25.25%" headers="mcps1.2.4.1.2 "><p id="zh-cn_topic_0000001117163542_p195145331840"><a name="zh-cn_topic_0000001117163542_p195145331840"></a><a name="zh-cn_topic_0000001117163542_p195145331840"></a><a href="#zh-cn_topic_0000001117163542_section256244135613">StorageObserver</a></p> 1781</td> 1782<td class="cellrowborder" valign="top" width="50.690000000000005%" headers="mcps1.2.4.1.3 "><p id="zh-cn_topic_0000001117163542_p95141333546"><a name="zh-cn_topic_0000001117163542_p95141333546"></a><a name="zh-cn_topic_0000001117163542_p95141333546"></a>当有数据变化时会收到此回调</p> 1783</td> 1784</tr> 1785</tbody> 1786</table> 1787 1788## StorageObserver<a name="zh-cn_topic_0000001117163542_section256244135613"></a> 1789 1790<a name="zh-cn_topic_0000001117163542_table0103172561814"></a> 1791<table><thead align="left"><tr id="zh-cn_topic_0000001117163542_row12103152513185"><th class="cellrowborder" valign="top" width="17.931793179317932%" id="mcps1.1.5.1.1"><p id="zh-cn_topic_0000001117163542_p1610322561817"><a name="zh-cn_topic_0000001117163542_p1610322561817"></a><a name="zh-cn_topic_0000001117163542_p1610322561817"></a>名称</p> 1792</th> 1793<th class="cellrowborder" valign="top" width="12.271227122712272%" id="mcps1.1.5.1.2"><p id="zh-cn_topic_0000001117163542_p20103132551816"><a name="zh-cn_topic_0000001117163542_p20103132551816"></a><a name="zh-cn_topic_0000001117163542_p20103132551816"></a>参数类型</p> 1794</th> 1795<th class="cellrowborder" valign="top" width="10.551055105510551%" id="mcps1.1.5.1.3"><p id="zh-cn_topic_0000001117163542_p1103172518188"><a name="zh-cn_topic_0000001117163542_p1103172518188"></a><a name="zh-cn_topic_0000001117163542_p1103172518188"></a>必填</p> 1796</th> 1797<th class="cellrowborder" valign="top" width="59.245924592459254%" id="mcps1.1.5.1.4"><p id="zh-cn_topic_0000001117163542_p19103125141812"><a name="zh-cn_topic_0000001117163542_p19103125141812"></a><a name="zh-cn_topic_0000001117163542_p19103125141812"></a>说明</p> 1798</th> 1799</tr> 1800</thead> 1801<tbody><tr id="zh-cn_topic_0000001117163542_row201031125101812"><td class="cellrowborder" valign="top" width="17.931793179317932%" headers="mcps1.1.5.1.1 "><p id="zh-cn_topic_0000001117163542_p5549181319415"><a name="zh-cn_topic_0000001117163542_p5549181319415"></a><a name="zh-cn_topic_0000001117163542_p5549181319415"></a>key</p> 1802</td> 1803<td class="cellrowborder" valign="top" width="12.271227122712272%" headers="mcps1.1.5.1.2 "><p id="zh-cn_topic_0000001117163542_p39351925253"><a name="zh-cn_topic_0000001117163542_p39351925253"></a><a name="zh-cn_topic_0000001117163542_p39351925253"></a>string</p> 1804</td> 1805<td class="cellrowborder" valign="top" width="10.551055105510551%" headers="mcps1.1.5.1.3 "><p id="zh-cn_topic_0000001117163542_p8935162182512"><a name="zh-cn_topic_0000001117163542_p8935162182512"></a><a name="zh-cn_topic_0000001117163542_p8935162182512"></a>否</p> 1806</td> 1807<td class="cellrowborder" valign="top" width="59.245924592459254%" headers="mcps1.1.5.1.4 "><p id="zh-cn_topic_0000001117163542_p109351224253"><a name="zh-cn_topic_0000001117163542_p109351224253"></a><a name="zh-cn_topic_0000001117163542_p109351224253"></a>变更的数据内容</p> 1808</td> 1809</tr> 1810</tbody> 1811</table> 1812 1813