Skip to content

Commit 3f5cfbd

Browse files
authored
readme/doc vue3
1 parent 76e89e5 commit 3f5cfbd

File tree

1 file changed

+45
-1
lines changed

1 file changed

+45
-1
lines changed

packages/collectionview/blueprint.md

Lines changed: 45 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,51 @@ If you want to use multiple item templates, you can do that very similarly to ho
191191

192192
For a more complete example, look in the `demo-ng` directory.
193193

194-
## Usage in Vue
194+
## Usage in Vue 3
195+
196+
Register the plugin in your `app.ts`.
197+
198+
```ts
199+
import CollectionView from '@nativescript-community/ui-collectionview/vue3';
200+
201+
const app = createApp(YourComponent);
202+
app.use(CollectionView);
203+
app.start();
204+
```
205+
206+
### Simple Example
207+
In your component, add the following to make a simple array of objects.
208+
209+
```html
210+
<script setup lang="ts">
211+
import { ObservableArray } from '@nativescript/core';
212+
import { ref } from "nativescript-vue";
213+
214+
const itemList = ref(new ObservableArray([
215+
{ name: 'TURQUOISE', color: '#1abc9c' },
216+
{ name: 'EMERALD', color: '#2ecc71' },
217+
{ name: 'PETER RIVER', color: '#3498db' },
218+
{ name: 'AMETHYST', color: '#9b59b6' },
219+
{ name: 'WET ASPHALT', color: '#34495e' }
220+
]));
221+
</script>
222+
```
223+
224+
Then add the following XML to your component.
225+
226+
```xml
227+
<CollectionView :items="itemList" colWidth="50%" rowHeight="100">
228+
<template #default="{ item }">
229+
<StackLayout :backgroundColor="item.color" >
230+
<Label :text="item.name"/>
231+
</StackLayout>
232+
</template>
233+
</CollectionView>
234+
```
235+
236+
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.
237+
238+
## Usage in Vue 2
195239

196240
Register the plugin in your `app.ts`.
197241

0 commit comments

Comments
 (0)