Vue introduces its own JS file to write

Source: Internet
Author: User

Not much to say, directly on the code AH ~

Let's start with a structure diagram:

The VUE-CLI wrote a JS file of his own.

Then I want to introduce it into the Vue component.

1. First write my JS file

2. Introduction to VUE Components!!! Be sure to use {} to get the name of the method.

3. Can be happy to use the

"About introducing third-party plugins: Simply say three ways"

I. can be introduced directly into the Index.html CDN, remember to put in front of </body> OH

Two. Configure Webpack:

1. First package.json join in,

"jquery" : "^2.2.3"}

2. Installation dependent

NPM Install jquery --save-dev

3 webpack.base.conf.js . Join in

var webpack = require("webpack")
4, the last addition in the Module.exports

plugins: [ new webpack.optimize.CommonsChunkPlugin(‘common.js‘), new webpack.ProvidePlugin({ jQuery: "jquery", $: "jquery" }) ]

5. Then be sure to re-npm run dev

Will error: NPM install--save!! Vue-style-loader!css-loader

Execute command: NPM install stylus-loader css-loader style-loader--save-dev

6, the introduction of the Main.js is OK

import $ from ‘jquery‘

3. What if the plugin is written by someone who is not able to download the installation via NPM?

Reference: https://www.cnblogs.com/mengfangui/p/7552471.html

Reference: http://blog.csdn.net/meishuixingdeququ/article/details/76338632

Vue introduces its own JS file

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.