|
57 | 57 | * [Usage in Angular](#usage-in-angular) |
58 | 58 | * [Simple Example](#simple-example-1) |
59 | 59 | * [Templates Example](#templates-example-1) |
60 | | -* [Usage in Vue](#usage-in-vue) |
| 60 | +* [Usage in Vue 3](#usage-in-vue-3) |
61 | 61 | * [Simple Example](#simple-example-2) |
62 | | -* [Usage in Svelte](#usage-in-svelte) |
| 62 | +* [Usage in Vue 2](#usage-in-vue-2) |
63 | 63 | * [Simple Example](#simple-example-3) |
64 | | -* [Usage in React](#usage-in-react) |
| 64 | +* [Usage in Svelte](#usage-in-svelte) |
65 | 65 | * [Simple Example](#simple-example-4) |
| 66 | +* [Usage in React](#usage-in-react) |
| 67 | + * [Simple Example](#simple-example-5) |
66 | 68 | * [Demos](#demos) |
67 | 69 | * [Demos and Development](#demos-and-development) |
68 | 70 | * [Repo Setup](#repo-setup) |
@@ -283,12 +285,62 @@ If you want to use multiple item templates, you can do that very similarly to ho |
283 | 285 | For a more complete example, look in the `demo-ng` directory. |
284 | 286 |
|
285 | 287 |
|
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) |
287 | 339 |
|
288 | 340 |
|
289 | | -[](#usage-in-vue) |
| 341 | +[](#usage-in-vue-2) |
290 | 342 |
|
291 | | -## Usage in Vue |
| 343 | +## Usage in Vue 2 |
292 | 344 |
|
293 | 345 | Register the plugin in your `app.ts`. |
294 | 346 |
|
|
0 commit comments