同步操作将从 OpenHarmony/docs 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
import parameter from '@ohos.systemparameter'
None
Gets the value of the attribute with the specified key.
Parameters
Return Values
System attribute value. If the specified key does not exist, the default value is returned. If no default value has been set, an empty string will be returned. |
Example
try {
var info = parameter.getSync("test.parameter.key");
console.log(JSON.stringify(info));
}catch(e){
console.log("getSync unexpected error: " + e);
}
Gets the value of the attribute with the specified key.
Parameters
Return Values
None.
Example
try {
parameter.get("test.parameter.key", function (err, data) {
if (err == undefined) {
console.log("get test.parameter.key value success:" + data)
} else {
console.log(" get test.parameter.key value err:" + err.code)
}});
}catch(e){
console.log("get unexpected error: " + e);
}
Gets the value of the attribute with the specified key.
Parameters
Return Values
None.
Example
try {
parameter.get("test.parameter.key", "default", function (err, data) {
if (err == undefined) {
console.log("get test.parameter.key value success:" + data)
} else {
console.log(" get test.parameter.key value err:" + err.code)
}
});
}catch(e){
console.log("get unexpected error:" + e)
}
Gets the value of the attribute with the specified key.
Parameters
Return Values
Example
try {
var p = parameter.get("test.parameter.key");
p.then(function (value) {
console.log("get test.parameter.key success: " + value);
}).catch(function (err) {
console.log("get test.parameter.key error: " + err.code);
});
}catch(e){
console.log("get unexpected error: " + e);
}
Sets a value for the attribute with the specified key.
Parameters
Return Values
None.
Example
try {
parameter.setSync("test.parameter.key", "default");
}catch(e){
console.log("set unexpected error: " + e);
}
Sets a value for the attribute with the specified key.
Parameters
Return Values
None.
Example
try {
parameter.set("test.parameter.key", "testValue", function (err, data) {
if (err == undefined) {
console.log("set test.parameter.key value success :" + data)
} else {
console.log("set test.parameter.key value err:" + err.code)
}});
}catch(e){
console.log("set unexpected error: " + e);
}
Sets a value for the attribute with the specified key.
Parameters
Return Values
Example
try {
var p = para.set("test.parameter.key", "testValue");
p.then(function (value) {
console.log("set test.parameter.key success: " + value);
}).catch(function (err) {
console.log(" set test.parameter.key error: " + err.code);
});
}catch(e){
console.log("set unexpected error: " + e);
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。