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

    TypeError: Cannot read property 'clipboard' of undefined

    Framework
    1
    2
    949
    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.
    • K
      keechan last edited by

      I am adding copy to clipboard functionality on my app (using Electron).

      I use this command:

      methods: {
         copyToClipboard () {
             if (process.env.MODE === 'electron') {
                  this.$q.electron.clipboard.writeText(this.logText)
             }
         }
      }
      

      But then I get an error message:

      TypeError: Cannot read property 'clipboard' of undefined 
      

      I wonder why. On a separate vue file (main layout vue), I also call this.$q.electron functions (minimize, maximize, etc) and they work fine. The same functions when I try using this component also generates the same error.

      I initially used to do this but I need to change implementation since this doesn’t work when I build for web (I use web for Cypress testing):

      const { clipboard } = require('electron')
      clipboard.writeText(this.logText)
      

      Is this.$q.electron only allowed to be used on certain files/levels?

      1 Reply Last reply Reply Quote 0
      • K
        keechan last edited by

        Nevermind. Fixed this by using the built-in Quasar functoin copyToClipboard() instead.

        import { copyToClipboard } from 'quasar'
        

        Thanks

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