Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Starting page #5

Open
Cersin opened this issue Nov 22, 2022 · 7 comments
Open

Starting page #5

Cersin opened this issue Nov 22, 2022 · 7 comments

Comments

@Cersin
Copy link

Cersin commented Nov 22, 2022

Hi,
how to set start page?
I have something like this:
<Frame ~mainContent ref="drawerMainContent">


But i want to start with Routes.js, like in normal app

@MattCCC
Copy link
Owner

MattCCC commented Nov 22, 2022

Hi / cześć!

In the main *.vue file of your app try something like:

        <Frame ref="myFrameId"
            @loaded="onMainFrameLoaded"
        >
            <YourPageComponent />
        </Frame>

Where myFrameId is your frame Id, that you specify when calling $routeTo. Then onMainFrameLoaded is a callback when everything is ready.

But i want to start with Routes.js, like in normal app

I'm not sure I understand this part. You can use routes.js. Just import that file with const routes as per example, in wherever you require it.

@Cersin
Copy link
Author

Cersin commented Nov 22, 2022

@MattCCC siemka,
The problem is that when I start inside Frame I put component, but I would like to load if I have an authentication error, and the first time the route.beforeEach doesn't even start. I cant properly configure it, demo will be cool

@MattCCC
Copy link
Owner

MattCCC commented Nov 22, 2022

I'm not quite sure about your exact use case. I'll try to set up a demo in following days, and then make a new release. I have a bunch of small bug fixes here and there to include as well. Then we can follow up on that so let's keep the thread open 👍

and the first time the route.beforeEach doesn't even start

Does it load in standard web vue-router? If it does, then we may have an issue there.

@Cersin
Copy link
Author

Cersin commented Nov 22, 2022

Thanks, i will wait for a demo

@Cersin
Copy link
Author

Cersin commented Dec 5, 2022

any news? :D

@Cersin
Copy link
Author

Cersin commented Dec 6, 2022

@MattCCC there is now beta version with vue 3 support https://github.com/nativescript-vue/nativescript-vue

@vallemar
Copy link

vallemar commented Dec 7, 2022

Hi @MattCCC , the repository @Cersin is talking about was an effort to add this router to Vue3 when we were testing dominative. We got it working and now it works with ns-vue 3 beta as well. @MattCCC Would you commit to merging the changes or do we keep it in this fork?

@Cersin an example of what you want:

// app.ts
import { createApp } from 'nativescript-vue';
import App from './App.vue';
import {router} from "~/plugins/router";
const app = createApp(App);
app.use(router)
app.start();
// /plugins/router.ts
import {createRouter} from "router-vue-native";
import Home from "~/views/Home.vue";
import Login from "~/views/Login.vue";

const routes = [
    {
        path: "/",
        component: Home,
    },
    {
        path: "/login",
        component: Login,
    }
];

const router = createRouter(
    {routes},
);

export {
    router
}
// App.vue
<template>
  <RouterView defaultRoute="/login"></RouterView>
</template>

// OR

<script setup lang="ts">
const getDefaultRouteExample = () => {
  if (isLoginUser) {
    return "/login"
  } else {
    return "/"
  }
}
</script>
<template>
  <RouterView :defaultRoute="getDefaultRouteExample"></RouterView>
</template>

I want to update the readme so that it has these examples but first I would like to know in which repository and package this plugin will end up 🤣

Note: this is the fork https://github.com/ammarahm-ed/nativescript-vue-router-extended

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants