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

!11567 修改image示例

Merge pull request !11567 from 田雨/master
......@@ -349,53 +349,3 @@ struct ImageExample3 {
```
![zh-cn_image_0000001205972610](figures/zh-cn_image_0000001205972610.gif)
### 渲染沙箱路径图片
```
import fileio from '@ohos.fileio'
import image from '@ohos.multimedia.image'
const EMPTY_PATH = 'file://'
@Entry
@Component
struct LoadImageExample {
@State fileContent: string = ''
@State path: string = EMPTY_PATH
@State accountInfoHeadPic: any = ''
build() {
Column() {
Button('读取沙箱图片')
.margin({ bottom: 10 })
.onClick(() => {
try {
this.path = EMPTY_PATH
let context = getContext(this)
let path = context.getApplicationContext().filesDir + '/icon.png'
console.log(`读取沙箱图片=========>${path}`)
let fd = fileio.openSync(path, 0o100, 0o666)
console.log(`create file========>${fd}`)
let srcPath = context.bundleCodeDir + '/entry/resource/base/media/icon.png'
fileio.copyFileSync(srcPath, path)
console.log(`error:=============>${e.message}`)
}
})
Button('读取资源图片')
.margin({ bottom: 10 })
.onClick(() => {
this.path = EMPTY_PATH;
this.path += getContext(this.bundleCodeDir + '/entry/resource/base/media/icon.png')
})
Text(`图片路径:${this.path}`)
.fontSize(20)
.margin({ bottom: 10 })
Image(this.path)
.width(100)
.height(100)
}
.width('100%').height('100%')
}
}
```
\ No newline at end of file
......@@ -78,7 +78,7 @@ import router from '@ohos.router'
@Component
struct DetailExample {
// 接收Navigator.ets的传参
@State text: any = router.getParams().text
@State text: any = router.getParams()['text']
build() {
Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Start, justifyContent: FlexAlign.SpaceBetween }) {
......
......@@ -71,7 +71,7 @@ struct Example {
}
```
![zh-cn_image_0000001169582302](figures/zh-cn_image_0000001169582302.gif)
![zh-cn_image_0000001169582302](figures/zh-cn_image_0000001169582302.png)
## 相关实例
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册