Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -532,6 +532,27 @@ or a document, put a `<nc-viewer-file>` there, give it the file and a size:
<nc-viewer-file :file.prop="file" style="width: 280px; height: 180px" />
```

`<nc-viewer-file>` is a custom element, not a Vue component. In a Vue
template, tell the compiler, or it tries to resolve it as a component and
warns on every render:

```ts
// vite.config.ts
vue({ template: { compilerOptions: { isCustomElement: (tag) => tag === 'nc-viewer-file' } } })
```

Where the build does not let you set that, as with `@nextcloud/vite-config`,
render it as a dynamic component, which Vue renders as a plain element
without resolving it:

```vue
<component :is="viewerFileTag" :file.prop="file" />
```

with `viewerFileTag = 'nc-viewer-file'` in the component's data or setup. A
constant rather than a literal, which linters turn into a static `is`. Bind
`file` with `.prop` either way: it is a DOM property, not an attribute.

```ts
const element = document.createElement('nc-viewer-file')
element.file = file
Expand Down
Loading