I use vue-router and jQuery in the template,when i switch router $(document).ready() is failure

后端 未结 2 1084
感情败类
感情败类 2021-01-24 06:36

I do not know jQuery in vue correct usage. When I refresh page, $(document).ready() has a role. But when I switch the page through vue-router, $(document).rea

2条回答
  •  暗喜
    暗喜 (楼主)
    2021-01-24 07:12

    I know that you've probably got the answer you were looking for, but for those who came here to find a way to use jQuery inside vue:

    you should just add a script tag on your index.html file and after that you can use $ variable whenever the component is created by vue. just like one of life cycle hooks that Saurabh mentioned, or as a method invoked by a v-on directive.

    e.g.:

    
    
    
    
    
    

提交回复
热议问题