Home Web Front-end JS Tutorial How to use bootstrap in vue-cli project

How to use bootstrap in vue-cli project

Jun 02, 2018 pm 02:26 PM
vue-cli use

This time I will show you how to use bootstrap in the vue-cli project. What are the precautions for using bootstrap in the vue-cli project. The following is a practical case. Let’s take a look.

It is very convenient to add bootstrap to an html page. You just need to pass the css and js files through the Link and Script tags.

So how to add it to a front-end project generated with vue-vli? Because the framework is different, it takes some getting used to.

InstallationPlug-in

1

2

3

npm install jquery --save

npm install bootstrap --save

npm install popper.js --save

Copy after login

Configuration webpack.base.conf.js

1

2

//在顶部添加

const webpack = require('webpack')

Copy after login

1

2

3

4

5

6

7

8

9

10

//在module.exports = {}末尾添加下面代码

module.exports = {

...

plugins: [

  new webpack.ProvidePlugin({

   $: "jquery",

   jQuery: "jquery"

  })

 ]

}

Copy after login

Add

1

2

import $ from 'jquery'

import 'bootstrap'

Copy after login

Test jquery to main.js

1

2

3

4

5

6

7

8

9

//在vue文件中添加测试代码

<script>

$(function () {

 alert('234')

})

export default {

 name: 'App'

}

</script>

Copy after login

Testing bootstrap

1

2

3

4

5

6

7

8

9

<template>

<p class="container">

  <p class="row">

    <p class="col-md-6">

      <button class="btn btn-primary">测试按钮</button>

    </p>

  </p>

</p>

</template>

Copy after login

I believe you have mastered the method after reading the case in this article. For more exciting information, please pay attention to other related articles on the php Chinese website!

Recommended reading:

How to use vue.js and element-ui to implement the menu tree structure

How to use vue Inner .sync modifier

The above is the detailed content of How to use bootstrap in vue-cli project. For more information, please follow other related articles on the PHP Chinese website!

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot Article Tags

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

How to use magnet links How to use magnet links Feb 18, 2024 am 10:02 AM

How to use magnet links

How to use mdf and mds files How to use mdf and mds files Feb 19, 2024 pm 05:36 PM

How to use mdf and mds files

What software is crystaldiskmark? -How to use crystaldiskmark? What software is crystaldiskmark? -How to use crystaldiskmark? Mar 18, 2024 pm 02:58 PM

What software is crystaldiskmark? -How to use crystaldiskmark?

How to download foobar2000? -How to use foobar2000 How to download foobar2000? -How to use foobar2000 Mar 18, 2024 am 10:58 AM

How to download foobar2000? -How to use foobar2000

How to use Baidu Netdisk app How to use Baidu Netdisk app Mar 27, 2024 pm 06:46 PM

How to use Baidu Netdisk app

How to use Xiaoai Speaker How to connect Xiaoai Speaker to mobile phone How to use Xiaoai Speaker How to connect Xiaoai Speaker to mobile phone Feb 22, 2024 pm 05:19 PM

How to use Xiaoai Speaker How to connect Xiaoai Speaker to mobile phone

How to use NetEase Mailbox Master How to use NetEase Mailbox Master Mar 27, 2024 pm 05:32 PM

How to use NetEase Mailbox Master

Simple guide to pip mirror source: easily master how to use it Simple guide to pip mirror source: easily master how to use it Jan 16, 2024 am 10:18 AM

Simple guide to pip mirror source: easily master how to use it

See all articles