No More Posting New Topics!

If you have a question or an issue, please start a thread in our Github Discussions Forum.
This forum is closed for new threads/ topics.

Navigation

    Quasar Framework

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search

    Trigger a function on page load (solved)

    Help
    3
    6
    2907
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • M
      mattiabilla last edited by mattiabilla

      Hi everybody, I’m trying to trigger a function (or a method) (for instance an axios request) when the page is loaded. I tried with computed or mounted but it doesn’t work.

      1 Reply Last reply Reply Quote 0
      • S
        Sujan Dev last edited by

        you can call your method from created or mounted. it should work, you can use console.log() to check that function is called or not.

        M 1 Reply Last reply Reply Quote 0
        • M
          mattiabilla @Sujan Dev last edited by

          @sujan-dev I tried but it didn’t work. Nothing appeared.

          S 1 Reply Last reply Reply Quote 0
          • S
            Sujan Dev @mattiabilla last edited by

            @mattiabilla can you share your code

            1 Reply Last reply Reply Quote -1
            • S
              Sweetyy last edited by Sweetyy

              Hi @mattiabilla ,

              Just to be sure, did you do it like that ?

              <script>
              export default {
                data () {},
                methods: {
                  myFunction () {
                    console.log('Hi my name is myFunction')
                  }
                },
                created () {
                  this.myFunction()
                }
              }
              </script>
              

              Hope it will help 🙂

              M 1 Reply Last reply Reply Quote 0
              • M
                mattiabilla @Sweetyy last edited by

                @sweetyy This works perfectly. Thanks 🙂

                1 Reply Last reply Reply Quote 0
                • First post
                  Last post