search

Home  >  Q&A  >  body text

How to view the Vue method bound to an element when inspecting the element in a browser such as chrome?

As we all know, in the previous jq era, event handling functions could be added by adding attributes such as onclick to the tag. In this case, you can know which method is bound by right-clicking on the element in the browser, and you can even see which line in the code this method is on.
However, after the emergence of Vue, wanting to know what a button does has become a headache. @click='method' written in the source code will be processed and hidden by Vue, so that it cannot be seen directly. If the button action is correct, you still have to find it in the source code, which is very inefficient. So the question is, how can we directly see in the browser which Vue method the button is bound to and which line it is on?

世界只因有你世界只因有你2750 days ago1081

reply all(5)I'll reply

  • 三叔

    三叔2017-06-26 10:57:57

    It seems that no one knows, and no one has thought about this problem. Forget it, I’ll just write a plug-in myself

    reply
    0
  • 習慣沉默

    習慣沉默2017-06-26 10:57:57

    You can use vue-devtools

    reply
    0
  • typecho

    typecho2017-06-26 10:57:57

    Right-click the source code of the web page to view it, find the binding processing method directly on the relevant element, and then search in the relevant js in the source panel to locate a specific line.

    reply
    0
  • ringa_lee

    ringa_lee2017-06-26 10:57:57

    View events of DOM elements:

    Click directly on the first one, open the Vue file, and then set a breakpoint. After breaking to the breakpoint, you can see which method fn is bound to:

    Enter fn in the console, hit Enter, and then click the output method name:

    How to automatically jump to Sources:

    reply
    0
  • 代言

    代言2017-06-26 10:57:57

    https://chrome.google.com/web...

    reply
    0
  • Cancelreply