0

I want to do if the child route is open I want to give class="user" margin-right:200px and I want to use transition while doing this. I also want transition to be done when I turn off the router.

This Is The Route I Have

[
  {
    path: 'user',
    component: () => import('../pages/User/User.vue'),
    name: 'user',
    children: [
      {
        path: 'new',
        component: () => import('../pages/User/UserNew.vue'),
        name: 'userNew',
      },
    ]
  }
]

User.vue

<template>
        <div class="main">
                <div class="user">Hello JACK
                        <router-link :to="{ name: 'userNew'}">
                                <span>Add User</span>
                        </router-link>
                </div>
                <div class="Form">
                        <router-view v-slot="{ Component }">
                                <transition name="route">
                                        <component :is="Component"/>
                                </transition>
                        </router-view>
                </div>
        </div>
</template>

<script>
export default {
        name: "User"
}
</script>

UserNew.vue

<template>
        <div class="">
                <button @click="this.$router.go(-1)">Close</button>
                <form action="">
                        <label for="email">Email</label>
                        <input type="email" id="email">
                </form>
        </div>
</template>

<script>
export default {
        name: "UserNew"
}
</script>
kissu
  • 40,416
  • 14
  • 65
  • 133
kralyolda
  • 115
  • 1
  • 8
  • Hi, did you gave a read to that one? https://vuejs.org/guide/built-ins/transition.html You'll need to create some CSS variables for the transition to be effective. This can also be useful: https://router.vuejs.org/guide/advanced/transitions.html – kissu Nov 22 '22 at 12:12
  • I looked, but since it is not possible for me to solve it, I opened a question here. please reply for your answers. – kralyolda Nov 22 '22 at 12:25
  • What is not working exactly? Some effort is required from your side (cannot see any CSS tries here). We're not supposed to code you the whole thing. Also, there is probably a question like yours on Stackoverflow already. – kissu Nov 22 '22 at 12:27
  • I couldn't solve the css side, if you can help as css – kralyolda Nov 22 '22 at 12:28
  • From my first comment, [some example](https://sfc.vuejs.org/#eNqFks1u2zAMx1+F0ynFYivdMKDw1GK77AXWQw+6KDadqJUlQaLdL/TdS8VN+okWMCSSFn+kqP+9+BtjPY0oGqFym2ykM+3xJoZE0GFvRkdwrz1AZ8gsjmYbICGNye89gLwN1w1QGnGOPJSNF/6UPHDZIRyiM4TFI7UeiYKHP62z7dWpFgUDp/Ct7FqcnYfNxiH8d7ZD+A7/TIdKzjmcD6DOk/HZkmWGNwMWQjlb9XyS8+deVISpsv0TnsNbdC4oGWeGfIZwQMmXHXqV6dYVs34GV+gJU2VashPOI6ADogHjHKzqnxnQZKzCSL93Y3iNcGgm/AJxkqEd17at1nhnMS2Olxz8VZaTJRwffYSdO+tTGJYf1aPwolYf0lCejM1y3YvFj1W8KVSAEE1r6baB1VyEn3A3BrEUdijSqAYT68scPMtmR9RPP7IWzV4VWrCuiq/FlijmRsrct0Vsl7kOaSPZqtPoyQ5YYx6qdQrXGRODteD+DwzJwYnvldB3mDB9xnxz9B13r0vx8AizgAaZ). – kissu Nov 22 '22 at 12:32
  • I tried but it doesn't work :S – kralyolda Nov 22 '22 at 12:37
  • "it doesn't work" is quite limited from a debugging standing point. Please be more explicit as of what: you tried, what is not working, what you wish to have. – kissu Nov 22 '22 at 12:42

0 Answers0