提交 600d18d0 编写于 作者: P PaDaBoo

修改await关键字的示例代码

Signed-off-by: NPaDaBoo <xuejianwu@huawei.com>
上级 04321f71
...@@ -43,7 +43,7 @@ getPreferences(context: Context, name: string, callback: AsyncCallback&lt;Prefer ...@@ -43,7 +43,7 @@ getPreferences(context: Context, name: string, callback: AsyncCallback&lt;Prefer
``` ```
import Ability from '@ohos.application.Ability' import Ability from '@ohos.application.Ability'
import data_Preferences from '@ohos.data.preferences' import data_Preferences from '@ohos.data.preferences'
var path = await this.context.getDataBaseDir() var path = this.context.getDataBaseDir()
data_Preferences.getPreferences(this.context, 'mystore', function (err, preferences) { data_Preferences.getPreferences(this.context, 'mystore', function (err, preferences) {
if (err) { if (err) {
console.info("Get the preferences failed, path: " + path + '/mystore') console.info("Get the preferences failed, path: " + path + '/mystore')
...@@ -78,7 +78,7 @@ getPreferences(context: Context, name: string): Promise&lt;Preferences&gt; ...@@ -78,7 +78,7 @@ getPreferences(context: Context, name: string): Promise&lt;Preferences&gt;
``` ```
import Ability from '@ohos.application.Ability' import Ability from '@ohos.application.Ability'
import data_Preferences from '@ohos.data.preferences' import data_Preferences from '@ohos.data.preferences'
var path = await this.context.getDataBaseDir() var path = this.context.getDataBaseDir()
let promise = data_Preferences.getPreferences(this.context, 'mystore') let promise = data_Preferences.getPreferences(this.context, 'mystore')
promise.then((preferences) => { promise.then((preferences) => {
preferences.putSync('startup', 'auto') preferences.putSync('startup', 'auto')
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册