How to Use jquery in a single-page vue application, vuejquery
Preface
This article describes how to use jquery in a single-page vue application. It mainly records the jquery method introduced in an application created by vue-cli that is used today. Let's not talk about it much below. Let's take a look at the detailed introduction.
The method is as follows:
1. It is preferred to install jquery through npm
Npm install jquery -- save
2. Introduce jquery In the build/webpack. base. conf file.
Module. exports = {... resolve: {extensions :['. js ','. vue ','. json '], alias: {'vue $': 'vue/dist/vue. esm. js', '@': resolve ('src'), 'jquery ': path. resolve (_ dirname ,'.. /node_modules/jquery/src/jquery ')}},...}
3. Where necessary
Import $ from 'jquery 'export default {name: 'hello', data () {return {msg: 'Welcome to Your Vue. js App '}}, mounted: function () {let test = $ (' # test '). text () console. log (test)}, methods :{}}
Summary
The above is all about this article. I hope this article will help you learn or use vue. If you have any questions, please leave a message, thank you for your support.