|
| 1 | +<script lang="ts" setup> |
| 2 | +import { |
| 3 | +ref, |
| 4 | +computed, |
| 5 | +onMounted, |
| 6 | +onUnmounted, |
| 7 | +$navigateTo, |
| 8 | +}from"nativescript-vue"; |
| 9 | +importDetailsfrom"./Details.vue"; |
| 10 | +
|
| 11 | +const counter=ref(0); |
| 12 | +const message=computed(()=> { |
| 13 | +return`Blank {N}-Vue app: ${counter.value}`; |
| 14 | +}); |
| 15 | +
|
| 16 | +function logMessage() { |
| 17 | +console.log("You have tapped the message!"); |
| 18 | +} |
| 19 | +
|
| 20 | +let interval:any; |
| 21 | +onMounted(()=> { |
| 22 | +console.log("mounted"); |
| 23 | +interval=setInterval(()=>counter.value++,100); |
| 24 | +}); |
| 25 | +
|
| 26 | +onUnmounted(()=> { |
| 27 | +console.log("unmounted"); |
| 28 | +clearInterval(interval); |
| 29 | +}); |
| 30 | +</script> |
| 31 | + |
| 32 | +<template> |
| 33 | + <Frame> |
| 34 | + <Page> |
| 35 | + <ActionBar> |
| 36 | + <Labeltext="Home"class="font-bold text-lg" /> |
| 37 | + </ActionBar> |
| 38 | + |
| 39 | + <GridLayoutrows="*, auto, auto, *"class="px-4"> |
| 40 | + <Label |
| 41 | +row="1" |
| 42 | +class="text-xl align-middle text-center text-gray-500" |
| 43 | +:text="message" |
| 44 | +@tap="logMessage" |
| 45 | + /> |
| 46 | + |
| 47 | + <Button |
| 48 | +row="2" |
| 49 | +@tap="$navigateTo(Details)" |
| 50 | +class="mt-4 px-4 py-2 bg-white border-2 border-blue-400 rounded-lg" |
| 51 | +horizontalAlignment="center" |
| 52 | + > |
| 53 | + View Details |
| 54 | + </Button> |
| 55 | + </GridLayout> |
| 56 | + </Page> |
| 57 | + </Frame> |
| 58 | +</template> |
| 59 | + |
| 60 | +<style> |
| 61 | +/* .info { |
| 62 | + font-size: 20; |
| 63 | + }*/ |
| 64 | +</style> |