English
fs-file-preview
About 202 wordsLess than 1 minute
Introduction
fs-file-preview file preview component, built on FsFrame (SSO-authenticated iframe container). It enables inline preview of file attachments within mini programs.
Automatically resolves preview URLs and renders content via FsFrame.
Usage
Declare the component in your page's index.json:
{
"usingComponents": {
"fs-file-preview": "ava-ui/fxui/fs-file-preview/index"
}
}Use in WXML:
<fs-file-preview
path="{{filePath}}"
ext="{{fileExt}}"
previewUrl="{{previewUrl}}"
isAliCloud="{{isAliCloud}}"
height="100%"
bind:load="onPreviewLoad"
/>Properties
| Property | Type | Default | Required | Description |
|---|---|---|---|---|
| path | String | '' | Yes | File path (npath) |
| ext | String | '' | No | File extension (e.g. docx, png) |
| filename | String | '' | No | File name |
| previewUrl | String | '' | No | Preview URL (if provided, used directly) |
| isAliCloud | Boolean | false | No | Whether the file is on AliCloud storage |
| height | String | '100%' | No | Preview area height |
Events
| Name | Detail | Description |
|---|---|---|
| load | { url } | FsFrame loaded successfully |
| message | iframe postMessage data | Message received from iframe |
Notes
- Depends on
FsFramecomponent andfs-hera-api - Preview URL resolution: provide
previewUrldirectly for immediate use, or providepathfor automatic resolution vianpath2Url - AliCloud files are resolved through the
dps/preview/getPreviewConfigV2API - SSO authentication is handled automatically by FsFrame's login-iframe wrapper
