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