Vue's two ways of importing bootstrap and jquery

Source: Internet
Author: User

There are two main ways in which Vue introduces Bootstrap

Method One: introduced in Main.js, this method imports the bootstrap for HTML,the body of some of the pre-set CSS style may not be valid.

First, the introduction of jQuery

In the current project directory (that is , Package.json), run the command cnpm install jquery--save-dev If you run an error, run cnpm install jquery (cnpm and C12>NPM will be able to install jquery in this project.

Then modify the webpack.base.conf.js ( under the build file ) Two places:

1: Join

var webpack=require (' Webpack ');

2 join in the Module.exports

plugins:[   new webpack.optimize.CommonsChunkPlugin (' Common.js '),     New  Webpack. Provideplugin ({        "jquery",        "jquery"   })]

Finally , add the import $ Form ' jquery' to main.jsto complete the introduction of jquery

Ii. introduction of bootstrap.css files:

Modify webpack.base.conf.js

resolve:{Extensions: ['. js ', '. Vue ', '. JSON '], alias: { ' vue$ ': ' Vue/dist/vue.esm.js ', ' @ ': Resolve (' src '), ' Bootstrap ': Resolve (' src/assets/bootstrap ')

Import introduced in Main.js

Import ' bootstrap/js/bootstrap.min.js 'import' bootstrap/css/bootstrap.min.css '

Method Two: introduced in index.html, it is generally recommended to use this method to introduce bootstrap.

When introducing bootstrap in the index.html file, be aware that the response is not implemented when you add the <meta> tag to implement the response, and when the tag is not present, the phone mode may appear.

<meta name= "Viewport"      content= "Width=device-width, User-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0 "><meta http-equiv=" x-ua-compatible "content=" Ie=edge ">

(1) Local references:

The bootstrap file to be loaded in the static directory is first delegated

And then introduce it in the index.html.

The directory path is the path to the location you have placed.

(2) Remote introduction:

Direct loading of remote bootstrap files

Vue's two ways of importing bootstrap and jquery

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.