2👍
You can directly do it in Vue, but if you wanted to use jQuery then you can write the jQuery code in the mounted
or created
hook. Also you can use the jQuery code in the methods as well.
new Vue({
el: "#app",
mounted () {
$('.add').on('click',function() {
alert('Add');
});
}
})
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.5.17/vue.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div id="app">
<button class="add">Button</button>
</div>
- [Vuejs]-What is the correct way of using axios.post in Vue 3?
- [Vuejs]-I get an infinite loop when i try to navigata to login page
1👍
Don’t use jquery .. it’s easy to solve in vuejs
<button @click="alert('Add')">Button</button>
Source:stackexchange.com