Need help with app (storage, router, variables)

Hello
I develop an app, and would be grateful for your help.

  1. Providing variables with setup() there only right way to make them reactive? There is no data-section as in vanilla vue?
  2. How access to component variables from methods? Now I use passing as parameter when it called from template, is this right way?
  3. How to use router.push in setup() and inside methods?
  4. How create component variable with data from Storage? It still empty after assignment in setup().

Aaron Saunders has some great how-to videos for Vue 3 and Ionic on YouTube. Take a look at his examples.

Also look at my newvue project on github. Pay attention to the const/ref/return parts of the setup. The “title” attribute is reactive and updated by clicking on the button.

1 Like

a lot of these question are answered in the starter app tutorial here: https://ionicframework.com/docs/vue/your-first-app

Thank you guys!
Ok, my first three problems was because I defined function inside methods{} instead setup(), now it work fine.
But I still have question about passing data from Capacitor Storage. For example, I kept user name in storage, and want to show it at main component (App.vue).

setup() {

const user = Storage.get({key: ‘user’}).then(item => (return item.value));

return { user }
}

But field {{ user }} empty and doesnt changed. If I do like this:

let user = “”;
Storage.get({key: ‘user’}).then(item => (
user = item.value;
console.log(user);
));

It will show in console that value is assigned.

UPD: seem I make mistake again, I forgot to use “value” property to assign new value.

const user = Storage.get({key: ‘user’}).then(item => (
user.value = item.value;
));