What is the difference between `path` and `fullPath` in VueJS router?










0















In my router.js file, when I'm using the beforeEach method, I get path and fullPath in the properties of to and from parameters. I'm wondering which one I should use for redirection purpose. I've seen both been used and I don't when to use which, and what is the difference between both.



An exemple:



export default new Router(
mode: 'history',
base: process.env.BASE_URL,
routes: [
path: 'login'
beforeEnter: (to, from, next) =>
console.log(to, from) // the routes
if (User.loggedIn())
next(from.fullPath) // or maybe `from.path`
else
next()

,
]
)









share|improve this question






















  • $route.fullPath :The full resolved URL including query and hash. $route.path:A string that equals the path of the current route, always resolved as an absolute path. e.g. "/foo/bar".

    – Mars.Tsai
    Nov 13 '18 at 10:08















0















In my router.js file, when I'm using the beforeEach method, I get path and fullPath in the properties of to and from parameters. I'm wondering which one I should use for redirection purpose. I've seen both been used and I don't when to use which, and what is the difference between both.



An exemple:



export default new Router(
mode: 'history',
base: process.env.BASE_URL,
routes: [
path: 'login'
beforeEnter: (to, from, next) =>
console.log(to, from) // the routes
if (User.loggedIn())
next(from.fullPath) // or maybe `from.path`
else
next()

,
]
)









share|improve this question






















  • $route.fullPath :The full resolved URL including query and hash. $route.path:A string that equals the path of the current route, always resolved as an absolute path. e.g. "/foo/bar".

    – Mars.Tsai
    Nov 13 '18 at 10:08













0












0








0








In my router.js file, when I'm using the beforeEach method, I get path and fullPath in the properties of to and from parameters. I'm wondering which one I should use for redirection purpose. I've seen both been used and I don't when to use which, and what is the difference between both.



An exemple:



export default new Router(
mode: 'history',
base: process.env.BASE_URL,
routes: [
path: 'login'
beforeEnter: (to, from, next) =>
console.log(to, from) // the routes
if (User.loggedIn())
next(from.fullPath) // or maybe `from.path`
else
next()

,
]
)









share|improve this question














In my router.js file, when I'm using the beforeEach method, I get path and fullPath in the properties of to and from parameters. I'm wondering which one I should use for redirection purpose. I've seen both been used and I don't when to use which, and what is the difference between both.



An exemple:



export default new Router(
mode: 'history',
base: process.env.BASE_URL,
routes: [
path: 'login'
beforeEnter: (to, from, next) =>
console.log(to, from) // the routes
if (User.loggedIn())
next(from.fullPath) // or maybe `from.path`
else
next()

,
]
)






javascript vuejs2 vue-router






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 13 '18 at 10:03









Ulysse BNUlysse BN

2,29011231




2,29011231












  • $route.fullPath :The full resolved URL including query and hash. $route.path:A string that equals the path of the current route, always resolved as an absolute path. e.g. "/foo/bar".

    – Mars.Tsai
    Nov 13 '18 at 10:08

















  • $route.fullPath :The full resolved URL including query and hash. $route.path:A string that equals the path of the current route, always resolved as an absolute path. e.g. "/foo/bar".

    – Mars.Tsai
    Nov 13 '18 at 10:08
















$route.fullPath :The full resolved URL including query and hash. $route.path:A string that equals the path of the current route, always resolved as an absolute path. e.g. "/foo/bar".

– Mars.Tsai
Nov 13 '18 at 10:08





$route.fullPath :The full resolved URL including query and hash. $route.path:A string that equals the path of the current route, always resolved as an absolute path. e.g. "/foo/bar".

– Mars.Tsai
Nov 13 '18 at 10:08












2 Answers
2






active

oldest

votes


















1














From the Vue API Reference:





  • $route.fullPath
    • type: string

      The full resolved URL including query and hash.



  • $route.path
    • type: string

      A string that equals the path of the current route, always resolved as an absolute path. e.g. "/foo/bar".







share|improve this answer
































    0














    path: A string that is equal to the path of the current route,
    always resolved as an absolute path.
    Example: /user/11/posts, /user/37/posts



    fullPath: The complete URL, including query and hash.



    Others...



    params: An object that contains key / value pairs of
    segments.
    query: An object that contains key / value pairs of the
    url value string. For example, for
    / foo? user = 1, we have $ route.query.user == 1.
    hash: The hash of the current path (without #), if one exists. If
    no hash is present, value will be a string
    empty.
    matched: An Array containing route records for all
    nested path segments of the current route. The
    route records are the copies of the objects in the
    route configuration.
    name: The name of the current route, if one exists.






    share|improve this answer






















      Your Answer






      StackExchange.ifUsing("editor", function ()
      StackExchange.using("externalEditor", function ()
      StackExchange.using("snippets", function ()
      StackExchange.snippets.init();
      );
      );
      , "code-snippets");

      StackExchange.ready(function()
      var channelOptions =
      tags: "".split(" "),
      id: "1"
      ;
      initTagRenderer("".split(" "), "".split(" "), channelOptions);

      StackExchange.using("externalEditor", function()
      // Have to fire editor after snippets, if snippets enabled
      if (StackExchange.settings.snippets.snippetsEnabled)
      StackExchange.using("snippets", function()
      createEditor();
      );

      else
      createEditor();

      );

      function createEditor()
      StackExchange.prepareEditor(
      heartbeatType: 'answer',
      autoActivateHeartbeat: false,
      convertImagesToLinks: true,
      noModals: true,
      showLowRepImageUploadWarning: true,
      reputationToPostImages: 10,
      bindNavPrevention: true,
      postfix: "",
      imageUploader:
      brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
      contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
      allowUrls: true
      ,
      onDemand: true,
      discardSelector: ".discard-answer"
      ,immediatelyShowMarkdownHelp:true
      );



      );













      draft saved

      draft discarded


















      StackExchange.ready(
      function ()
      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53278447%2fwhat-is-the-difference-between-path-and-fullpath-in-vuejs-router%23new-answer', 'question_page');

      );

      Post as a guest















      Required, but never shown

























      2 Answers
      2






      active

      oldest

      votes








      2 Answers
      2






      active

      oldest

      votes









      active

      oldest

      votes






      active

      oldest

      votes









      1














      From the Vue API Reference:





      • $route.fullPath
        • type: string

          The full resolved URL including query and hash.



      • $route.path
        • type: string

          A string that equals the path of the current route, always resolved as an absolute path. e.g. "/foo/bar".







      share|improve this answer





























        1














        From the Vue API Reference:





        • $route.fullPath
          • type: string

            The full resolved URL including query and hash.



        • $route.path
          • type: string

            A string that equals the path of the current route, always resolved as an absolute path. e.g. "/foo/bar".







        share|improve this answer



























          1












          1








          1







          From the Vue API Reference:





          • $route.fullPath
            • type: string

              The full resolved URL including query and hash.



          • $route.path
            • type: string

              A string that equals the path of the current route, always resolved as an absolute path. e.g. "/foo/bar".







          share|improve this answer















          From the Vue API Reference:





          • $route.fullPath
            • type: string

              The full resolved URL including query and hash.



          • $route.path
            • type: string

              A string that equals the path of the current route, always resolved as an absolute path. e.g. "/foo/bar".








          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Nov 13 '18 at 11:06









          Ulysse BN

          2,29011231




          2,29011231










          answered Nov 13 '18 at 10:34







          user10608712






























              0














              path: A string that is equal to the path of the current route,
              always resolved as an absolute path.
              Example: /user/11/posts, /user/37/posts



              fullPath: The complete URL, including query and hash.



              Others...



              params: An object that contains key / value pairs of
              segments.
              query: An object that contains key / value pairs of the
              url value string. For example, for
              / foo? user = 1, we have $ route.query.user == 1.
              hash: The hash of the current path (without #), if one exists. If
              no hash is present, value will be a string
              empty.
              matched: An Array containing route records for all
              nested path segments of the current route. The
              route records are the copies of the objects in the
              route configuration.
              name: The name of the current route, if one exists.






              share|improve this answer



























                0














                path: A string that is equal to the path of the current route,
                always resolved as an absolute path.
                Example: /user/11/posts, /user/37/posts



                fullPath: The complete URL, including query and hash.



                Others...



                params: An object that contains key / value pairs of
                segments.
                query: An object that contains key / value pairs of the
                url value string. For example, for
                / foo? user = 1, we have $ route.query.user == 1.
                hash: The hash of the current path (without #), if one exists. If
                no hash is present, value will be a string
                empty.
                matched: An Array containing route records for all
                nested path segments of the current route. The
                route records are the copies of the objects in the
                route configuration.
                name: The name of the current route, if one exists.






                share|improve this answer

























                  0












                  0








                  0







                  path: A string that is equal to the path of the current route,
                  always resolved as an absolute path.
                  Example: /user/11/posts, /user/37/posts



                  fullPath: The complete URL, including query and hash.



                  Others...



                  params: An object that contains key / value pairs of
                  segments.
                  query: An object that contains key / value pairs of the
                  url value string. For example, for
                  / foo? user = 1, we have $ route.query.user == 1.
                  hash: The hash of the current path (without #), if one exists. If
                  no hash is present, value will be a string
                  empty.
                  matched: An Array containing route records for all
                  nested path segments of the current route. The
                  route records are the copies of the objects in the
                  route configuration.
                  name: The name of the current route, if one exists.






                  share|improve this answer













                  path: A string that is equal to the path of the current route,
                  always resolved as an absolute path.
                  Example: /user/11/posts, /user/37/posts



                  fullPath: The complete URL, including query and hash.



                  Others...



                  params: An object that contains key / value pairs of
                  segments.
                  query: An object that contains key / value pairs of the
                  url value string. For example, for
                  / foo? user = 1, we have $ route.query.user == 1.
                  hash: The hash of the current path (without #), if one exists. If
                  no hash is present, value will be a string
                  empty.
                  matched: An Array containing route records for all
                  nested path segments of the current route. The
                  route records are the copies of the objects in the
                  route configuration.
                  name: The name of the current route, if one exists.







                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered Nov 13 '18 at 10:38









                  Hamilton GabrielHamilton Gabriel

                  965




                  965



























                      draft saved

                      draft discarded
















































                      Thanks for contributing an answer to Stack Overflow!


                      • Please be sure to answer the question. Provide details and share your research!

                      But avoid


                      • Asking for help, clarification, or responding to other answers.

                      • Making statements based on opinion; back them up with references or personal experience.

                      To learn more, see our tips on writing great answers.




                      draft saved


                      draft discarded














                      StackExchange.ready(
                      function ()
                      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53278447%2fwhat-is-the-difference-between-path-and-fullpath-in-vuejs-router%23new-answer', 'question_page');

                      );

                      Post as a guest















                      Required, but never shown





















































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown

































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown







                      這個網誌中的熱門文章

                      Barbados

                      How to read a connectionString WITH PROVIDER in .NET Core?

                      Node.js Script on GitHub Pages or Amazon S3