• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# 系统属性<a name="ZH-CN_TOPIC_0000001210295633"></a>
2
3## 导入模块<a name="zh-cn_topic_0000001094819718_section370mcpsimp"></a>
4
5```
6import parameter from '@ohos.systemParameter'
7```
8
9## 权限列表<a name="zh-cn_topic_0000001094819718_section373mcpsimp"></a>
10
1112
13## 方法<a name="zh-cn_topic_0000001094819718_section1319529172015"></a>
14
15## getSync\(key: string, def?: string\)<a name="zh-cn_topic_0000001094819718_section3381192816421"></a>
16
17获取系统属性Key对应的值。
18
19**参数:**
20
21<a name="zh-cn_topic_0000001094819718_table14473145217456"></a>
22<table><thead align="left"><tr id="zh-cn_topic_0000001094819718_row1052235294518"><th class="cellrowborder" valign="top" width="11.219999999999999%" id="mcps1.1.5.1.1"><p id="zh-cn_topic_0000001094819718_p15522195234514"><a name="zh-cn_topic_0000001094819718_p15522195234514"></a><a name="zh-cn_topic_0000001094819718_p15522195234514"></a>参数名</p>
23</th>
24<th class="cellrowborder" valign="top" width="13.270000000000001%" id="mcps1.1.5.1.2"><p id="zh-cn_topic_0000001094819718_p1852285215454"><a name="zh-cn_topic_0000001094819718_p1852285215454"></a><a name="zh-cn_topic_0000001094819718_p1852285215454"></a>类型</p>
25</th>
26<th class="cellrowborder" valign="top" width="8.16%" id="mcps1.1.5.1.3"><p id="zh-cn_topic_0000001094819718_p125221452154514"><a name="zh-cn_topic_0000001094819718_p125221452154514"></a><a name="zh-cn_topic_0000001094819718_p125221452154514"></a>必填</p>
27</th>
28<th class="cellrowborder" valign="top" width="67.35%" id="mcps1.1.5.1.4"><p id="zh-cn_topic_0000001094819718_p552214521459"><a name="zh-cn_topic_0000001094819718_p552214521459"></a><a name="zh-cn_topic_0000001094819718_p552214521459"></a>说明</p>
29</th>
30</tr>
31</thead>
32<tbody><tr id="zh-cn_topic_0000001094819718_row165221352124511"><td class="cellrowborder" valign="top" width="11.219999999999999%" headers="mcps1.1.5.1.1 "><p id="zh-cn_topic_0000001094819718_p85221523450"><a name="zh-cn_topic_0000001094819718_p85221523450"></a><a name="zh-cn_topic_0000001094819718_p85221523450"></a>key</p>
33</td>
34<td class="cellrowborder" valign="top" width="13.270000000000001%" headers="mcps1.1.5.1.2 "><p id="zh-cn_topic_0000001094819718_p1452275204516"><a name="zh-cn_topic_0000001094819718_p1452275204516"></a><a name="zh-cn_topic_0000001094819718_p1452275204516"></a>string</p>
35</td>
36<td class="cellrowborder" valign="top" width="8.16%" headers="mcps1.1.5.1.3 "><p id="zh-cn_topic_0000001094819718_p1152275224511"><a name="zh-cn_topic_0000001094819718_p1152275224511"></a><a name="zh-cn_topic_0000001094819718_p1152275224511"></a>是</p>
37</td>
38<td class="cellrowborder" valign="top" width="67.35%" headers="mcps1.1.5.1.4 "><p id="zh-cn_topic_0000001094819718_p175228526455"><a name="zh-cn_topic_0000001094819718_p175228526455"></a><a name="zh-cn_topic_0000001094819718_p175228526455"></a>待查询的系统属性Key。</p>
39</td>
40</tr>
41<tr id="zh-cn_topic_0000001094819718_row12676182816132"><td class="cellrowborder" valign="top" width="11.219999999999999%" headers="mcps1.1.5.1.1 "><p id="zh-cn_topic_0000001094819718_p567652819135"><a name="zh-cn_topic_0000001094819718_p567652819135"></a><a name="zh-cn_topic_0000001094819718_p567652819135"></a>def</p>
42</td>
43<td class="cellrowborder" valign="top" width="13.270000000000001%" headers="mcps1.1.5.1.2 "><p id="zh-cn_topic_0000001094819718_p156769289137"><a name="zh-cn_topic_0000001094819718_p156769289137"></a><a name="zh-cn_topic_0000001094819718_p156769289137"></a>string</p>
44</td>
45<td class="cellrowborder" valign="top" width="8.16%" headers="mcps1.1.5.1.3 "><p id="zh-cn_topic_0000001094819718_p96763289138"><a name="zh-cn_topic_0000001094819718_p96763289138"></a><a name="zh-cn_topic_0000001094819718_p96763289138"></a>否</p>
46</td>
47<td class="cellrowborder" valign="top" width="67.35%" headers="mcps1.1.5.1.4 "><p id="zh-cn_topic_0000001094819718_p16761628121319"><a name="zh-cn_topic_0000001094819718_p16761628121319"></a><a name="zh-cn_topic_0000001094819718_p16761628121319"></a>默认值。</p>
48</td>
49</tr>
50</tbody>
51</table>
52
53**返回值:**
54
55<a name="zh-cn_topic_0000001094819718_table1926815519481"></a>
56<table><thead align="left"><tr id="zh-cn_topic_0000001094819718_row92682052486"><th class="cellrowborder" valign="top" width="16.46%" id="mcps1.1.3.1.1"><p id="zh-cn_topic_0000001094819718_p326920564820"><a name="zh-cn_topic_0000001094819718_p326920564820"></a><a name="zh-cn_topic_0000001094819718_p326920564820"></a>类型</p>
57</th>
58<th class="cellrowborder" valign="top" width="83.54%" id="mcps1.1.3.1.2"><p id="zh-cn_topic_0000001094819718_p1126911514486"><a name="zh-cn_topic_0000001094819718_p1126911514486"></a><a name="zh-cn_topic_0000001094819718_p1126911514486"></a>说明</p>
59</th>
60</tr>
61</thead>
62<tbody><tr id="zh-cn_topic_0000001094819718_row12269165164818"><td class="cellrowborder" valign="top" width="16.46%" headers="mcps1.1.3.1.1 "><p id="zh-cn_topic_0000001094819718_p12269145144816"><a name="zh-cn_topic_0000001094819718_p12269145144816"></a><a name="zh-cn_topic_0000001094819718_p12269145144816"></a>string</p>
63</td>
64<td class="cellrowborder" valign="top" width="83.54%" headers="mcps1.1.3.1.2 "><p id="zh-cn_topic_0000001094819718_p026955154811"><a name="zh-cn_topic_0000001094819718_p026955154811"></a><a name="zh-cn_topic_0000001094819718_p026955154811"></a>系统属性值,若key不存在,返回默认值。若未指定默认值,返回空字符串。</p>
65</td>
66</tr>
67</tbody>
68</table>
69
70**示例:**
71
72```
73try {
74    var info = parameter.getSync("test.parameter.key");
75    console.log(JSON.stringify(info));
76}catch(e){
77    console.log("getSync unexpected error: " + e);
78}
79```
80
81## get\(key: string, callback: AsyncCallback<string\>\)<a name="zh-cn_topic_0000001094819718_section19655131534912"></a>
82
83获取系统属性Key对应的值。
84
85**参数:**
86
87<a name="zh-cn_topic_0000001094819718_table76561515144911"></a>
88<table><thead align="left"><tr id="zh-cn_topic_0000001094819718_row165611155491"><th class="cellrowborder" valign="top" width="10.979547900968782%" id="mcps1.1.5.1.1"><p id="zh-cn_topic_0000001094819718_p146561115114920"><a name="zh-cn_topic_0000001094819718_p146561115114920"></a><a name="zh-cn_topic_0000001094819718_p146561115114920"></a>参数名</p>
89</th>
90<th class="cellrowborder" valign="top" width="19.806243272335845%" id="mcps1.1.5.1.2"><p id="zh-cn_topic_0000001094819718_p2656111554911"><a name="zh-cn_topic_0000001094819718_p2656111554911"></a><a name="zh-cn_topic_0000001094819718_p2656111554911"></a>类型</p>
91</th>
92<th class="cellrowborder" valign="top" width="5.930130149721108%" id="mcps1.1.5.1.3"><p id="zh-cn_topic_0000001094819718_p12656121504916"><a name="zh-cn_topic_0000001094819718_p12656121504916"></a><a name="zh-cn_topic_0000001094819718_p12656121504916"></a>必填</p>
93</th>
94<th class="cellrowborder" valign="top" width="63.28407867697427%" id="mcps1.1.5.1.4"><p id="zh-cn_topic_0000001094819718_p14656415104917"><a name="zh-cn_topic_0000001094819718_p14656415104917"></a><a name="zh-cn_topic_0000001094819718_p14656415104917"></a>说明</p>
95</th>
96</tr>
97</thead>
98<tbody><tr id="zh-cn_topic_0000001094819718_row46561715194912"><td class="cellrowborder" valign="top" width="10.979547900968782%" headers="mcps1.1.5.1.1 "><p id="zh-cn_topic_0000001094819718_p11656715154910"><a name="zh-cn_topic_0000001094819718_p11656715154910"></a><a name="zh-cn_topic_0000001094819718_p11656715154910"></a>key</p>
99</td>
100<td class="cellrowborder" valign="top" width="19.806243272335845%" headers="mcps1.1.5.1.2 "><p id="zh-cn_topic_0000001094819718_p66561515204914"><a name="zh-cn_topic_0000001094819718_p66561515204914"></a><a name="zh-cn_topic_0000001094819718_p66561515204914"></a>string</p>
101</td>
102<td class="cellrowborder" valign="top" width="5.930130149721108%" headers="mcps1.1.5.1.3 "><p id="zh-cn_topic_0000001094819718_p065691514917"><a name="zh-cn_topic_0000001094819718_p065691514917"></a><a name="zh-cn_topic_0000001094819718_p065691514917"></a>是</p>
103</td>
104<td class="cellrowborder" valign="top" width="63.28407867697427%" headers="mcps1.1.5.1.4 "><p id="zh-cn_topic_0000001094819718_p8656111544920"><a name="zh-cn_topic_0000001094819718_p8656111544920"></a><a name="zh-cn_topic_0000001094819718_p8656111544920"></a>待查询的系统属性Key。</p>
105</td>
106</tr>
107<tr id="zh-cn_topic_0000001094819718_row1263818717506"><td class="cellrowborder" valign="top" width="10.979547900968782%" headers="mcps1.1.5.1.1 "><p id="zh-cn_topic_0000001094819718_p663817735014"><a name="zh-cn_topic_0000001094819718_p663817735014"></a><a name="zh-cn_topic_0000001094819718_p663817735014"></a>callback</p>
108</td>
109<td class="cellrowborder" valign="top" width="19.806243272335845%" headers="mcps1.1.5.1.2 "><p id="zh-cn_topic_0000001094819718_p12638872501"><a name="zh-cn_topic_0000001094819718_p12638872501"></a><a name="zh-cn_topic_0000001094819718_p12638872501"></a>AsyncCallback&lt;string&gt;</p>
110</td>
111<td class="cellrowborder" valign="top" width="5.930130149721108%" headers="mcps1.1.5.1.3 "><p id="zh-cn_topic_0000001094819718_p863847125019"><a name="zh-cn_topic_0000001094819718_p863847125019"></a><a name="zh-cn_topic_0000001094819718_p863847125019"></a>是</p>
112</td>
113<td class="cellrowborder" valign="top" width="63.28407867697427%" headers="mcps1.1.5.1.4 "><p id="zh-cn_topic_0000001094819718_p16638207205014"><a name="zh-cn_topic_0000001094819718_p16638207205014"></a><a name="zh-cn_topic_0000001094819718_p16638207205014"></a>回调函数。</p>
114</td>
115</tr>
116</tbody>
117</table>
118
119**返回值:**
120
121122
123**示例:**
124
125```
126try {
127    parameter.get("test.parameter.key", function (err, data) {
128    if (err == undefined) {
129        console.log("get test.parameter.key value success:" + data)
130    } else {
131        console.log(" get test.parameter.key value err:" + err.code)
132    }});
133}catch(e){
134    console.log("get unexpected error: " + e);
135}
136```
137
138## get\(key: string, def: string, callback: AsyncCallback<string\>\)<a name="zh-cn_topic_0000001094819718_section045334733915"></a>
139
140获取系统属性Key对应的值。
141
142**参数:**
143
144<a name="zh-cn_topic_0000001094819718_table1545354713914"></a>
145<table><thead align="left"><tr id="zh-cn_topic_0000001094819718_row11453184743918"><th class="cellrowborder" valign="top" width="11.219999999999999%" id="mcps1.1.5.1.1"><p id="zh-cn_topic_0000001094819718_p045394710392"><a name="zh-cn_topic_0000001094819718_p045394710392"></a><a name="zh-cn_topic_0000001094819718_p045394710392"></a>参数名</p>
146</th>
147<th class="cellrowborder" valign="top" width="20.61%" id="mcps1.1.5.1.2"><p id="zh-cn_topic_0000001094819718_p7453647113916"><a name="zh-cn_topic_0000001094819718_p7453647113916"></a><a name="zh-cn_topic_0000001094819718_p7453647113916"></a>类型</p>
148</th>
149<th class="cellrowborder" valign="top" width="6.18%" id="mcps1.1.5.1.3"><p id="zh-cn_topic_0000001094819718_p745374763917"><a name="zh-cn_topic_0000001094819718_p745374763917"></a><a name="zh-cn_topic_0000001094819718_p745374763917"></a>必填</p>
150</th>
151<th class="cellrowborder" valign="top" width="61.99%" id="mcps1.1.5.1.4"><p id="zh-cn_topic_0000001094819718_p13453847103918"><a name="zh-cn_topic_0000001094819718_p13453847103918"></a><a name="zh-cn_topic_0000001094819718_p13453847103918"></a>说明</p>
152</th>
153</tr>
154</thead>
155<tbody><tr id="zh-cn_topic_0000001094819718_row2453174773917"><td class="cellrowborder" valign="top" width="11.219999999999999%" headers="mcps1.1.5.1.1 "><p id="zh-cn_topic_0000001094819718_p1545413471396"><a name="zh-cn_topic_0000001094819718_p1545413471396"></a><a name="zh-cn_topic_0000001094819718_p1545413471396"></a>key</p>
156</td>
157<td class="cellrowborder" valign="top" width="20.61%" headers="mcps1.1.5.1.2 "><p id="zh-cn_topic_0000001094819718_p145416477394"><a name="zh-cn_topic_0000001094819718_p145416477394"></a><a name="zh-cn_topic_0000001094819718_p145416477394"></a>string</p>
158</td>
159<td class="cellrowborder" valign="top" width="6.18%" headers="mcps1.1.5.1.3 "><p id="zh-cn_topic_0000001094819718_p15454124783916"><a name="zh-cn_topic_0000001094819718_p15454124783916"></a><a name="zh-cn_topic_0000001094819718_p15454124783916"></a>是</p>
160</td>
161<td class="cellrowborder" valign="top" width="61.99%" headers="mcps1.1.5.1.4 "><p id="zh-cn_topic_0000001094819718_p645454720398"><a name="zh-cn_topic_0000001094819718_p645454720398"></a><a name="zh-cn_topic_0000001094819718_p645454720398"></a>待查询的系统属性Key。</p>
162</td>
163</tr>
164<tr id="zh-cn_topic_0000001094819718_row1586513411413"><td class="cellrowborder" valign="top" width="11.219999999999999%" headers="mcps1.1.5.1.1 "><p id="zh-cn_topic_0000001094819718_p4866114116410"><a name="zh-cn_topic_0000001094819718_p4866114116410"></a><a name="zh-cn_topic_0000001094819718_p4866114116410"></a>def</p>
165</td>
166<td class="cellrowborder" valign="top" width="20.61%" headers="mcps1.1.5.1.2 "><p id="zh-cn_topic_0000001094819718_p286618418410"><a name="zh-cn_topic_0000001094819718_p286618418410"></a><a name="zh-cn_topic_0000001094819718_p286618418410"></a>string</p>
167</td>
168<td class="cellrowborder" valign="top" width="6.18%" headers="mcps1.1.5.1.3 "><p id="zh-cn_topic_0000001094819718_p148664412416"><a name="zh-cn_topic_0000001094819718_p148664412416"></a><a name="zh-cn_topic_0000001094819718_p148664412416"></a>是</p>
169</td>
170<td class="cellrowborder" valign="top" width="61.99%" headers="mcps1.1.5.1.4 "><p id="zh-cn_topic_0000001094819718_p188663413413"><a name="zh-cn_topic_0000001094819718_p188663413413"></a><a name="zh-cn_topic_0000001094819718_p188663413413"></a>默认值。</p>
171</td>
172</tr>
173<tr id="zh-cn_topic_0000001094819718_row34546477396"><td class="cellrowborder" valign="top" width="11.219999999999999%" headers="mcps1.1.5.1.1 "><p id="zh-cn_topic_0000001094819718_p1454134712395"><a name="zh-cn_topic_0000001094819718_p1454134712395"></a><a name="zh-cn_topic_0000001094819718_p1454134712395"></a>callback</p>
174</td>
175<td class="cellrowborder" valign="top" width="20.61%" headers="mcps1.1.5.1.2 "><p id="zh-cn_topic_0000001094819718_p19454047123915"><a name="zh-cn_topic_0000001094819718_p19454047123915"></a><a name="zh-cn_topic_0000001094819718_p19454047123915"></a>AsyncCallback&lt;string&gt;</p>
176</td>
177<td class="cellrowborder" valign="top" width="6.18%" headers="mcps1.1.5.1.3 "><p id="zh-cn_topic_0000001094819718_p445454783919"><a name="zh-cn_topic_0000001094819718_p445454783919"></a><a name="zh-cn_topic_0000001094819718_p445454783919"></a>是</p>
178</td>
179<td class="cellrowborder" valign="top" width="61.99%" headers="mcps1.1.5.1.4 "><p id="zh-cn_topic_0000001094819718_p1454124713391"><a name="zh-cn_topic_0000001094819718_p1454124713391"></a><a name="zh-cn_topic_0000001094819718_p1454124713391"></a>回调函数。</p>
180</td>
181</tr>
182</tbody>
183</table>
184
185**返回值:**
186
187188
189**示例:**
190
191```
192try {
193    parameter.get("test.parameter.key", "default", function (err, data) {
194        if (err == undefined) {
195            console.log("get test.parameter.key value success:" + data)
196        } else {
197            console.log(" get test.parameter.key value err:" + err.code)
198        }
199    });
200}catch(e){
201    console.log("get unexpected error:" + e)
202}
203```
204
205## get\(key: string, def?: string\)<a name="zh-cn_topic_0000001094819718_section10288162818402"></a>
206
207获取系统属性Key对应的值。
208
209**参数:**
210
211<a name="zh-cn_topic_0000001094819718_table1028882844020"></a>
212<table><thead align="left"><tr id="zh-cn_topic_0000001094819718_row132880285407"><th class="cellrowborder" valign="top" width="11.219999999999999%" id="mcps1.1.5.1.1"><p id="zh-cn_topic_0000001094819718_p1828872816408"><a name="zh-cn_topic_0000001094819718_p1828872816408"></a><a name="zh-cn_topic_0000001094819718_p1828872816408"></a>参数名</p>
213</th>
214<th class="cellrowborder" valign="top" width="13.270000000000001%" id="mcps1.1.5.1.2"><p id="zh-cn_topic_0000001094819718_p1328810281407"><a name="zh-cn_topic_0000001094819718_p1328810281407"></a><a name="zh-cn_topic_0000001094819718_p1328810281407"></a>类型</p>
215</th>
216<th class="cellrowborder" valign="top" width="8.16%" id="mcps1.1.5.1.3"><p id="zh-cn_topic_0000001094819718_p72881628154019"><a name="zh-cn_topic_0000001094819718_p72881628154019"></a><a name="zh-cn_topic_0000001094819718_p72881628154019"></a>必填</p>
217</th>
218<th class="cellrowborder" valign="top" width="67.35%" id="mcps1.1.5.1.4"><p id="zh-cn_topic_0000001094819718_p16288172814407"><a name="zh-cn_topic_0000001094819718_p16288172814407"></a><a name="zh-cn_topic_0000001094819718_p16288172814407"></a>说明</p>
219</th>
220</tr>
221</thead>
222<tbody><tr id="zh-cn_topic_0000001094819718_row52888288404"><td class="cellrowborder" valign="top" width="11.219999999999999%" headers="mcps1.1.5.1.1 "><p id="zh-cn_topic_0000001094819718_p4288128194010"><a name="zh-cn_topic_0000001094819718_p4288128194010"></a><a name="zh-cn_topic_0000001094819718_p4288128194010"></a>key</p>
223</td>
224<td class="cellrowborder" valign="top" width="13.270000000000001%" headers="mcps1.1.5.1.2 "><p id="zh-cn_topic_0000001094819718_p1528817286404"><a name="zh-cn_topic_0000001094819718_p1528817286404"></a><a name="zh-cn_topic_0000001094819718_p1528817286404"></a>string</p>
225</td>
226<td class="cellrowborder" valign="top" width="8.16%" headers="mcps1.1.5.1.3 "><p id="zh-cn_topic_0000001094819718_p62895286409"><a name="zh-cn_topic_0000001094819718_p62895286409"></a><a name="zh-cn_topic_0000001094819718_p62895286409"></a>是</p>
227</td>
228<td class="cellrowborder" valign="top" width="67.35%" headers="mcps1.1.5.1.4 "><p id="zh-cn_topic_0000001094819718_p4289142812409"><a name="zh-cn_topic_0000001094819718_p4289142812409"></a><a name="zh-cn_topic_0000001094819718_p4289142812409"></a>待查询的系统属性Key。</p>
229</td>
230</tr>
231<tr id="zh-cn_topic_0000001094819718_row828962817403"><td class="cellrowborder" valign="top" width="11.219999999999999%" headers="mcps1.1.5.1.1 "><p id="zh-cn_topic_0000001094819718_p1289152874016"><a name="zh-cn_topic_0000001094819718_p1289152874016"></a><a name="zh-cn_topic_0000001094819718_p1289152874016"></a>def</p>
232</td>
233<td class="cellrowborder" valign="top" width="13.270000000000001%" headers="mcps1.1.5.1.2 "><p id="zh-cn_topic_0000001094819718_p228922815406"><a name="zh-cn_topic_0000001094819718_p228922815406"></a><a name="zh-cn_topic_0000001094819718_p228922815406"></a>string</p>
234</td>
235<td class="cellrowborder" valign="top" width="8.16%" headers="mcps1.1.5.1.3 "><p id="zh-cn_topic_0000001094819718_p19289428184020"><a name="zh-cn_topic_0000001094819718_p19289428184020"></a><a name="zh-cn_topic_0000001094819718_p19289428184020"></a>否</p>
236</td>
237<td class="cellrowborder" valign="top" width="67.35%" headers="mcps1.1.5.1.4 "><p id="zh-cn_topic_0000001094819718_p1428942818407"><a name="zh-cn_topic_0000001094819718_p1428942818407"></a><a name="zh-cn_topic_0000001094819718_p1428942818407"></a>默认值。</p>
238</td>
239</tr>
240</tbody>
241</table>
242
243**返回值:**
244
245<a name="zh-cn_topic_0000001094819718_table1644156114210"></a>
246<table><thead align="left"><tr id="zh-cn_topic_0000001094819718_row16441756114213"><th class="cellrowborder" valign="top" width="16.46%" id="mcps1.1.3.1.1"><p id="zh-cn_topic_0000001094819718_p564413569429"><a name="zh-cn_topic_0000001094819718_p564413569429"></a><a name="zh-cn_topic_0000001094819718_p564413569429"></a>类型</p>
247</th>
248<th class="cellrowborder" valign="top" width="83.54%" id="mcps1.1.3.1.2"><p id="zh-cn_topic_0000001094819718_p2644135684219"><a name="zh-cn_topic_0000001094819718_p2644135684219"></a><a name="zh-cn_topic_0000001094819718_p2644135684219"></a>说明</p>
249</th>
250</tr>
251</thead>
252<tbody><tr id="zh-cn_topic_0000001094819718_row126441156204215"><td class="cellrowborder" valign="top" width="16.46%" headers="mcps1.1.3.1.1 "><p id="zh-cn_topic_0000001094819718_p146441656144211"><a name="zh-cn_topic_0000001094819718_p146441656144211"></a><a name="zh-cn_topic_0000001094819718_p146441656144211"></a>Promise&lt;string&gt;</p>
253</td>
254<td class="cellrowborder" valign="top" width="83.54%" headers="mcps1.1.3.1.2 "><p id="zh-cn_topic_0000001094819718_p2644115664211"><a name="zh-cn_topic_0000001094819718_p2644115664211"></a><a name="zh-cn_topic_0000001094819718_p2644115664211"></a>Promise示例,用于异步获取结果。</p>
255</td>
256</tr>
257</tbody>
258</table>
259
260**示例:**
261
262```
263try {
264    var p = parameter.get("test.parameter.key");
265    p.then(function (value) {
266        console.log("get test.parameter.key success: " + value);
267    }).catch(function (err) {
268        console.log("get test.parameter.key error: " + err.code);
269    });
270}catch(e){
271    console.log("get unexpected error: " + e);
272}
273```
274
275## setSync\(key: string, value: string\)<a name="zh-cn_topic_0000001094819718_section63102185493"></a>
276
277设置系统属性Key对应的值。
278
279**参数:**
280
281<a name="zh-cn_topic_0000001094819718_table15310418174916"></a>
282<table><thead align="left"><tr id="zh-cn_topic_0000001094819718_row15311121811495"><th class="cellrowborder" valign="top" width="11.219999999999999%" id="mcps1.1.5.1.1"><p id="zh-cn_topic_0000001094819718_p19311101814493"><a name="zh-cn_topic_0000001094819718_p19311101814493"></a><a name="zh-cn_topic_0000001094819718_p19311101814493"></a>参数名</p>
283</th>
284<th class="cellrowborder" valign="top" width="13.270000000000001%" id="mcps1.1.5.1.2"><p id="zh-cn_topic_0000001094819718_p18311118204915"><a name="zh-cn_topic_0000001094819718_p18311118204915"></a><a name="zh-cn_topic_0000001094819718_p18311118204915"></a>类型</p>
285</th>
286<th class="cellrowborder" valign="top" width="8.16%" id="mcps1.1.5.1.3"><p id="zh-cn_topic_0000001094819718_p11311131894919"><a name="zh-cn_topic_0000001094819718_p11311131894919"></a><a name="zh-cn_topic_0000001094819718_p11311131894919"></a>必填</p>
287</th>
288<th class="cellrowborder" valign="top" width="67.35%" id="mcps1.1.5.1.4"><p id="zh-cn_topic_0000001094819718_p1131161804919"><a name="zh-cn_topic_0000001094819718_p1131161804919"></a><a name="zh-cn_topic_0000001094819718_p1131161804919"></a>说明</p>
289</th>
290</tr>
291</thead>
292<tbody><tr id="zh-cn_topic_0000001094819718_row183114182499"><td class="cellrowborder" valign="top" width="11.219999999999999%" headers="mcps1.1.5.1.1 "><p id="zh-cn_topic_0000001094819718_p12311141816498"><a name="zh-cn_topic_0000001094819718_p12311141816498"></a><a name="zh-cn_topic_0000001094819718_p12311141816498"></a>key</p>
293</td>
294<td class="cellrowborder" valign="top" width="13.270000000000001%" headers="mcps1.1.5.1.2 "><p id="zh-cn_topic_0000001094819718_p931121804918"><a name="zh-cn_topic_0000001094819718_p931121804918"></a><a name="zh-cn_topic_0000001094819718_p931121804918"></a>string</p>
295</td>
296<td class="cellrowborder" valign="top" width="8.16%" headers="mcps1.1.5.1.3 "><p id="zh-cn_topic_0000001094819718_p10311161874910"><a name="zh-cn_topic_0000001094819718_p10311161874910"></a><a name="zh-cn_topic_0000001094819718_p10311161874910"></a>是</p>
297</td>
298<td class="cellrowborder" valign="top" width="67.35%" headers="mcps1.1.5.1.4 "><p id="zh-cn_topic_0000001094819718_p531161819498"><a name="zh-cn_topic_0000001094819718_p531161819498"></a><a name="zh-cn_topic_0000001094819718_p531161819498"></a>待设置的系统属性Key。</p>
299</td>
300</tr>
301<tr id="zh-cn_topic_0000001094819718_row11371940105211"><td class="cellrowborder" valign="top" width="11.219999999999999%" headers="mcps1.1.5.1.1 "><p id="zh-cn_topic_0000001094819718_p713019471526"><a name="zh-cn_topic_0000001094819718_p713019471526"></a><a name="zh-cn_topic_0000001094819718_p713019471526"></a>value</p>
302</td>
303<td class="cellrowborder" valign="top" width="13.270000000000001%" headers="mcps1.1.5.1.2 "><p id="zh-cn_topic_0000001094819718_p1213013472526"><a name="zh-cn_topic_0000001094819718_p1213013472526"></a><a name="zh-cn_topic_0000001094819718_p1213013472526"></a>string</p>
304</td>
305<td class="cellrowborder" valign="top" width="8.16%" headers="mcps1.1.5.1.3 "><p id="zh-cn_topic_0000001094819718_p18130104735216"><a name="zh-cn_topic_0000001094819718_p18130104735216"></a><a name="zh-cn_topic_0000001094819718_p18130104735216"></a>是</p>
306</td>
307<td class="cellrowborder" valign="top" width="67.35%" headers="mcps1.1.5.1.4 "><p id="zh-cn_topic_0000001094819718_p141301747155214"><a name="zh-cn_topic_0000001094819718_p141301747155214"></a><a name="zh-cn_topic_0000001094819718_p141301747155214"></a>待设置的系统属性值。</p>
308</td>
309</tr>
310</tbody>
311</table>
312
313**返回值:**
314
315316
317**示例:**
318
319```
320try {
321    parameter.setSync("test.parameter.key", "default");
322}catch(e){
323    console.log("set unexpected error: " + e);
324}
325```
326
327## set\(key: string, value: string, callback: AsyncCallback<void\>\)<a name="zh-cn_topic_0000001094819718_section18770184911197"></a>
328
329设置系统属性Key对应的值。
330
331**参数:**
332
333<a name="zh-cn_topic_0000001094819718_table97701049101914"></a>
334<table><thead align="left"><tr id="zh-cn_topic_0000001094819718_row977164981919"><th class="cellrowborder" valign="top" width="10.93141075604053%" id="mcps1.1.5.1.1"><p id="zh-cn_topic_0000001094819718_p57712497198"><a name="zh-cn_topic_0000001094819718_p57712497198"></a><a name="zh-cn_topic_0000001094819718_p57712497198"></a>参数名</p>
335</th>
336<th class="cellrowborder" valign="top" width="16.630943102104442%" id="mcps1.1.5.1.2"><p id="zh-cn_topic_0000001094819718_p1077184911195"><a name="zh-cn_topic_0000001094819718_p1077184911195"></a><a name="zh-cn_topic_0000001094819718_p1077184911195"></a>类型</p>
337</th>
338<th class="cellrowborder" valign="top" width="6.819953234606392%" id="mcps1.1.5.1.3"><p id="zh-cn_topic_0000001094819718_p8771184913196"><a name="zh-cn_topic_0000001094819718_p8771184913196"></a><a name="zh-cn_topic_0000001094819718_p8771184913196"></a>必填</p>
339</th>
340<th class="cellrowborder" valign="top" width="65.61769290724864%" id="mcps1.1.5.1.4"><p id="zh-cn_topic_0000001094819718_p1677116491196"><a name="zh-cn_topic_0000001094819718_p1677116491196"></a><a name="zh-cn_topic_0000001094819718_p1677116491196"></a>说明</p>
341</th>
342</tr>
343</thead>
344<tbody><tr id="zh-cn_topic_0000001094819718_row1771194916198"><td class="cellrowborder" valign="top" width="10.93141075604053%" headers="mcps1.1.5.1.1 "><p id="zh-cn_topic_0000001094819718_p127713497196"><a name="zh-cn_topic_0000001094819718_p127713497196"></a><a name="zh-cn_topic_0000001094819718_p127713497196"></a>key</p>
345</td>
346<td class="cellrowborder" valign="top" width="16.630943102104442%" headers="mcps1.1.5.1.2 "><p id="zh-cn_topic_0000001094819718_p1777174912196"><a name="zh-cn_topic_0000001094819718_p1777174912196"></a><a name="zh-cn_topic_0000001094819718_p1777174912196"></a>string</p>
347</td>
348<td class="cellrowborder" valign="top" width="6.819953234606392%" headers="mcps1.1.5.1.3 "><p id="zh-cn_topic_0000001094819718_p577164914199"><a name="zh-cn_topic_0000001094819718_p577164914199"></a><a name="zh-cn_topic_0000001094819718_p577164914199"></a>是</p>
349</td>
350<td class="cellrowborder" valign="top" width="65.61769290724864%" headers="mcps1.1.5.1.4 "><p id="zh-cn_topic_0000001094819718_p27711349121916"><a name="zh-cn_topic_0000001094819718_p27711349121916"></a><a name="zh-cn_topic_0000001094819718_p27711349121916"></a>待查询的系统属性Key。</p>
351</td>
352</tr>
353<tr id="zh-cn_topic_0000001094819718_row117711549201917"><td class="cellrowborder" valign="top" width="10.93141075604053%" headers="mcps1.1.5.1.1 "><p id="zh-cn_topic_0000001094819718_p87711149111911"><a name="zh-cn_topic_0000001094819718_p87711149111911"></a><a name="zh-cn_topic_0000001094819718_p87711149111911"></a>def</p>
354</td>
355<td class="cellrowborder" valign="top" width="16.630943102104442%" headers="mcps1.1.5.1.2 "><p id="zh-cn_topic_0000001094819718_p1977134961915"><a name="zh-cn_topic_0000001094819718_p1977134961915"></a><a name="zh-cn_topic_0000001094819718_p1977134961915"></a>string</p>
356</td>
357<td class="cellrowborder" valign="top" width="6.819953234606392%" headers="mcps1.1.5.1.3 "><p id="zh-cn_topic_0000001094819718_p13771204911918"><a name="zh-cn_topic_0000001094819718_p13771204911918"></a><a name="zh-cn_topic_0000001094819718_p13771204911918"></a>是</p>
358</td>
359<td class="cellrowborder" valign="top" width="65.61769290724864%" headers="mcps1.1.5.1.4 "><p id="zh-cn_topic_0000001094819718_p1177117490192"><a name="zh-cn_topic_0000001094819718_p1177117490192"></a><a name="zh-cn_topic_0000001094819718_p1177117490192"></a>默认值。</p>
360</td>
361</tr>
362<tr id="zh-cn_topic_0000001094819718_row17771124917194"><td class="cellrowborder" valign="top" width="10.93141075604053%" headers="mcps1.1.5.1.1 "><p id="zh-cn_topic_0000001094819718_p207728494195"><a name="zh-cn_topic_0000001094819718_p207728494195"></a><a name="zh-cn_topic_0000001094819718_p207728494195"></a>callback</p>
363</td>
364<td class="cellrowborder" valign="top" width="16.630943102104442%" headers="mcps1.1.5.1.2 "><p id="zh-cn_topic_0000001094819718_p2077274961913"><a name="zh-cn_topic_0000001094819718_p2077274961913"></a><a name="zh-cn_topic_0000001094819718_p2077274961913"></a>AsyncCallback&lt;void&gt;</p>
365</td>
366<td class="cellrowborder" valign="top" width="6.819953234606392%" headers="mcps1.1.5.1.3 "><p id="zh-cn_topic_0000001094819718_p15772184914197"><a name="zh-cn_topic_0000001094819718_p15772184914197"></a><a name="zh-cn_topic_0000001094819718_p15772184914197"></a>是</p>
367</td>
368<td class="cellrowborder" valign="top" width="65.61769290724864%" headers="mcps1.1.5.1.4 "><p id="zh-cn_topic_0000001094819718_p1977244913198"><a name="zh-cn_topic_0000001094819718_p1977244913198"></a><a name="zh-cn_topic_0000001094819718_p1977244913198"></a>回调函数。</p>
369</td>
370</tr>
371</tbody>
372</table>
373
374**返回值:**
375
376377
378**示例:**
379
380```
381try {
382    parameter.set("test.parameter.key", "testValue", function (err, data) {
383    if (err == undefined) {
384        console.log("set test.parameter.key value success :" + data)
385    } else {
386        console.log("set test.parameter.key value err:" + err.code)
387    }});
388}catch(e){
389    console.log("set unexpected error: " + e);
390}
391```
392
393## set\(key: string, def?: string\)<a name="zh-cn_topic_0000001094819718_section187724496193"></a>
394
395设置系统属性Key对应的值。
396
397**参数:**
398
399<a name="zh-cn_topic_0000001094819718_table17724498192"></a>
400<table><thead align="left"><tr id="zh-cn_topic_0000001094819718_row277217498197"><th class="cellrowborder" valign="top" width="11.219999999999999%" id="mcps1.1.5.1.1"><p id="zh-cn_topic_0000001094819718_p57724491193"><a name="zh-cn_topic_0000001094819718_p57724491193"></a><a name="zh-cn_topic_0000001094819718_p57724491193"></a>参数名</p>
401</th>
402<th class="cellrowborder" valign="top" width="13.270000000000001%" id="mcps1.1.5.1.2"><p id="zh-cn_topic_0000001094819718_p6772134931918"><a name="zh-cn_topic_0000001094819718_p6772134931918"></a><a name="zh-cn_topic_0000001094819718_p6772134931918"></a>类型</p>
403</th>
404<th class="cellrowborder" valign="top" width="8.16%" id="mcps1.1.5.1.3"><p id="zh-cn_topic_0000001094819718_p577210499193"><a name="zh-cn_topic_0000001094819718_p577210499193"></a><a name="zh-cn_topic_0000001094819718_p577210499193"></a>必填</p>
405</th>
406<th class="cellrowborder" valign="top" width="67.35%" id="mcps1.1.5.1.4"><p id="zh-cn_topic_0000001094819718_p11773124941911"><a name="zh-cn_topic_0000001094819718_p11773124941911"></a><a name="zh-cn_topic_0000001094819718_p11773124941911"></a>说明</p>
407</th>
408</tr>
409</thead>
410<tbody><tr id="zh-cn_topic_0000001094819718_row677384921911"><td class="cellrowborder" valign="top" width="11.219999999999999%" headers="mcps1.1.5.1.1 "><p id="zh-cn_topic_0000001094819718_p677317495199"><a name="zh-cn_topic_0000001094819718_p677317495199"></a><a name="zh-cn_topic_0000001094819718_p677317495199"></a>key</p>
411</td>
412<td class="cellrowborder" valign="top" width="13.270000000000001%" headers="mcps1.1.5.1.2 "><p id="zh-cn_topic_0000001094819718_p177731049131913"><a name="zh-cn_topic_0000001094819718_p177731049131913"></a><a name="zh-cn_topic_0000001094819718_p177731049131913"></a>string</p>
413</td>
414<td class="cellrowborder" valign="top" width="8.16%" headers="mcps1.1.5.1.3 "><p id="zh-cn_topic_0000001094819718_p777324918197"><a name="zh-cn_topic_0000001094819718_p777324918197"></a><a name="zh-cn_topic_0000001094819718_p777324918197"></a>是</p>
415</td>
416<td class="cellrowborder" valign="top" width="67.35%" headers="mcps1.1.5.1.4 "><p id="zh-cn_topic_0000001094819718_p13773849191918"><a name="zh-cn_topic_0000001094819718_p13773849191918"></a><a name="zh-cn_topic_0000001094819718_p13773849191918"></a>待查询的系统属性Key。</p>
417</td>
418</tr>
419<tr id="zh-cn_topic_0000001094819718_row13773114921911"><td class="cellrowborder" valign="top" width="11.219999999999999%" headers="mcps1.1.5.1.1 "><p id="zh-cn_topic_0000001094819718_p1777374951915"><a name="zh-cn_topic_0000001094819718_p1777374951915"></a><a name="zh-cn_topic_0000001094819718_p1777374951915"></a>def</p>
420</td>
421<td class="cellrowborder" valign="top" width="13.270000000000001%" headers="mcps1.1.5.1.2 "><p id="zh-cn_topic_0000001094819718_p1877394921916"><a name="zh-cn_topic_0000001094819718_p1877394921916"></a><a name="zh-cn_topic_0000001094819718_p1877394921916"></a>string</p>
422</td>
423<td class="cellrowborder" valign="top" width="8.16%" headers="mcps1.1.5.1.3 "><p id="zh-cn_topic_0000001094819718_p1177314917194"><a name="zh-cn_topic_0000001094819718_p1177314917194"></a><a name="zh-cn_topic_0000001094819718_p1177314917194"></a>否</p>
424</td>
425<td class="cellrowborder" valign="top" width="67.35%" headers="mcps1.1.5.1.4 "><p id="zh-cn_topic_0000001094819718_p7773204917199"><a name="zh-cn_topic_0000001094819718_p7773204917199"></a><a name="zh-cn_topic_0000001094819718_p7773204917199"></a>默认值。</p>
426</td>
427</tr>
428</tbody>
429</table>
430
431**返回值:**
432
433<a name="zh-cn_topic_0000001094819718_table14773154913191"></a>
434<table><thead align="left"><tr id="zh-cn_topic_0000001094819718_row877314991912"><th class="cellrowborder" valign="top" width="16.46%" id="mcps1.1.3.1.1"><p id="zh-cn_topic_0000001094819718_p1077313493199"><a name="zh-cn_topic_0000001094819718_p1077313493199"></a><a name="zh-cn_topic_0000001094819718_p1077313493199"></a>类型</p>
435</th>
436<th class="cellrowborder" valign="top" width="83.54%" id="mcps1.1.3.1.2"><p id="zh-cn_topic_0000001094819718_p1677411498195"><a name="zh-cn_topic_0000001094819718_p1677411498195"></a><a name="zh-cn_topic_0000001094819718_p1677411498195"></a>说明</p>
437</th>
438</tr>
439</thead>
440<tbody><tr id="zh-cn_topic_0000001094819718_row1977413496194"><td class="cellrowborder" valign="top" width="16.46%" headers="mcps1.1.3.1.1 "><p id="zh-cn_topic_0000001094819718_p67742498197"><a name="zh-cn_topic_0000001094819718_p67742498197"></a><a name="zh-cn_topic_0000001094819718_p67742498197"></a>Promise&lt;string&gt;</p>
441</td>
442<td class="cellrowborder" valign="top" width="83.54%" headers="mcps1.1.3.1.2 "><p id="zh-cn_topic_0000001094819718_p4774164916199"><a name="zh-cn_topic_0000001094819718_p4774164916199"></a><a name="zh-cn_topic_0000001094819718_p4774164916199"></a>Promise示例,用于异步获取结果。</p>
443</td>
444</tr>
445</tbody>
446</table>
447
448**示例:**
449
450```
451try {
452    var p = para.set("test.parameter.key", "testValue");
453    p.then(function (value) {
454        console.log("set test.parameter.key success: " + value);
455    }).catch(function (err) {
456        console.log(" set test.parameter.key error: " + err.code);
457    });
458}catch(e){
459    console.log("set unexpected error: " + e);
460}
461```
462
463