How to Use jquery in a single-page vue application, vuejquery

Source: Internet
Author: User

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.