Skip to content

Commit b2bafdc

Browse files
committed
readme/doc
1 parent 596b0a1 commit b2bafdc

File tree

3 files changed

+93
-17
lines changed

3 files changed

+93
-17
lines changed

README.md

Lines changed: 58 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -57,12 +57,14 @@
5757
* [Usage in Angular](#usage-in-angular)
5858
* [Simple Example](#simple-example-1)
5959
* [Templates Example](#templates-example-1)
60-
* [Usage in Vue](#usage-in-vue)
60+
* [Usage in Vue 3](#usage-in-vue-3)
6161
* [Simple Example](#simple-example-2)
62-
* [Usage in Svelte](#usage-in-svelte)
62+
* [Usage in Vue 2](#usage-in-vue-2)
6363
* [Simple Example](#simple-example-3)
64-
* [Usage in React](#usage-in-react)
64+
* [Usage in Svelte](#usage-in-svelte)
6565
* [Simple Example](#simple-example-4)
66+
* [Usage in React](#usage-in-react)
67+
* [Simple Example](#simple-example-5)
6668
* [Demos](#demos)
6769
* [Demos and Development](#demos-and-development)
6870
* [Repo Setup](#repo-setup)
@@ -283,12 +285,62 @@ If you want to use multiple item templates, you can do that very similarly to ho
283285
For a more complete example, look in the `demo-ng` directory.
284286

285287

286-
[](#usage-in-vue)
288+
[](#usage-in-vue-3)
289+
290+
291+
[](#usage-in-vue-3)
292+
293+
## Usage in Vue 3
294+
295+
Register the plugin in your `app.ts`.
296+
297+
```ts
298+
import CollectionView from '@nativescript-community/ui-collectionview/vue3';
299+
300+
const app = createApp(YourComponent);
301+
app.use(CollectionView);
302+
app.start();
303+
```
304+
305+
### Simple Example
306+
In your component, add the following to make a simple array of objects.
307+
308+
```html
309+
<script setup lang="ts">
310+
import { ObservableArray } from '@nativescript/core';
311+
import { ref } from "nativescript-vue";
312+
313+
const itemList = ref(new ObservableArray([
314+
{ name: 'TURQUOISE', color: '#1abc9c' },
315+
{ name: 'EMERALD', color: '#2ecc71' },
316+
{ name: 'PETER RIVER', color: '#3498db' },
317+
{ name: 'AMETHYST', color: '#9b59b6' },
318+
{ name: 'WET ASPHALT', color: '#34495e' }
319+
]));
320+
</script>
321+
```
322+
323+
Then add the following XML to your component.
324+
325+
```xml
326+
<CollectionView :items="itemList" colWidth="50%" rowHeight="100">
327+
<template #default="{ item }">
328+
<StackLayout :backgroundColor="item.color" >
329+
<Label :text="item.name"/>
330+
</StackLayout>
331+
</template>
332+
</CollectionView>
333+
```
334+
335+
For a more complete example, look in the `demo-vue3` and [demo-snippets/vue3](https://github.com/nativescript-community/ui-collectionview/tree/master/demo-snippets/vue3) directory.
336+
337+
338+
[](#usage-in-vue-2)
287339

288340

289-
[](#usage-in-vue)
341+
[](#usage-in-vue-2)
290342

291-
## Usage in Vue
343+
## Usage in Vue 2
292344

293345
Register the plugin in your `app.ts`.
294346

docs/assets/search.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)