未验证 提交 cde34fe5 编写于 作者: O openharmony_ci 提交者: Gitee

!17530 优化ArkTS卡片开发指南示例代码

Merge pull request !17530 from zhongjianfei/mm0215
...@@ -64,7 +64,8 @@ ...@@ -64,7 +64,8 @@
// 建议下载能快速下载完成的小文件,如在5秒内未下载完成,则此次网络图片无法刷新至卡片页面上 // 建议下载能快速下载完成的小文件,如在5秒内未下载完成,则此次网络图片无法刷新至卡片页面上
let netFile = 'https://xxxx/xxxx.png'; // 需要在此处使用真实的网络图片下载链接 let netFile = 'https://xxxx/xxxx.png'; // 需要在此处使用真实的网络图片下载链接
let tempDir = this.context.getApplicationContext().tempDir; let tempDir = this.context.getApplicationContext().tempDir;
let tmpFile = tempDir + '/file' + Date.now(); let fileName = 'file' + Date.now();
let tmpFile = tempDir + '/' + fileName;
request.downloadFile(this.context, { request.downloadFile(this.context, {
url: netFile, filePath: tmpFile, enableMetered: true, enableRoaming: true url: netFile, filePath: tmpFile, enableMetered: true, enableRoaming: true
}).then((task) => { }).then((task) => {
...@@ -76,14 +77,14 @@ ...@@ -76,14 +77,14 @@
} catch (e) { } catch (e) {
console.error(`openSync failed: ${JSON.stringify(e)}`); console.error(`openSync failed: ${JSON.stringify(e)}`);
} }
let fileInfo = {};
fileInfo[fileName] = file.fd;
let formData = { let formData = {
'text': 'Image: Https', 'text': 'Image:' + fileName,
'imgName': 'imgHttps', 'imgName': fileName,
'formImages': { 'formImages': fileInfo,
'imgHttps': file.fd
},
'loaded': true 'loaded': true
} };
let formInfo = formBindingData.createFormBindingData(formData) let formInfo = formBindingData.createFormBindingData(formData)
formProvider.updateForm(formId, formInfo).then((data) => { formProvider.updateForm(formId, formInfo).then((data) => {
console.info('FormAbility updateForm success.' + JSON.stringify(data)); console.info('FormAbility updateForm success.' + JSON.stringify(data));
...@@ -108,7 +109,7 @@ ...@@ -108,7 +109,7 @@
``` ```
4. 在卡片页面通过Image组件展示EntryFormAbility传递过来的卡片内容。 4. 在卡片页面通过Image组件展示EntryFormAbility传递过来的卡片内容。
```ts ```ts
let storage = new LocalStorage(); let storage = new LocalStorage();
@Entry(storage) @Entry(storage)
...@@ -159,7 +160,6 @@ ...@@ -159,7 +160,6 @@
} }
``` ```
> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** > ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:**
> - Image组件通过入参(**memory://fileName**)中的**memory://**标识来进行远端内存图片显示,其中**fileName**需要和EntryFormAbility传递对象(**'formImages': {key: fd})**中的**key**相对应。 > - Image组件通过入参(**memory://fileName**)中的**memory://**标识来进行远端内存图片显示,其中**fileName**需要和EntryFormAbility传递对象(**'formImages': {key: fd})**中的**key**相对应。
> >
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册