2
2
3
3
## General
4
4
5
- If you are using module bundlers like [ webpack] ( https://webpack.js.org/ ) , [ rollup.js] ( https://rollupjs.org ) ,
6
- etc you may prefer to directly include the package into your project. To get started, use
7
- ` yarn ` or ` npm ` to get the latest version of Vue, BootstrapVue and Bootstrap 4:
5
+ If you are using module bundlers like [ webpack] ( https://webpack.js.org/ ) ,
6
+ [ rollup.js] ( https://rollupjs.org ) , etc you may prefer to directly include the package into your
7
+ project. To get started, use ` yarn ` or ` npm ` to get the latest version of Vue, BootstrapVue and
8
+ Bootstrap 4:
8
9
9
10
``` bash
10
11
# With npm
@@ -36,22 +37,21 @@ Or import Bootstrap and BootstrapVue `scss` files via a custom SCSS file:
36
37
37
38
``` scss
38
39
// custom.scss
39
- @import " node_modules/bootstrap/scss/bootstrap" ;
40
- @import " node_modules/bootstrap-vue/src/index.scss" ;
40
+ @import ' node_modules/bootstrap/scss/bootstrap' ;
41
+ @import ' node_modules/bootstrap-vue/src/index.scss' ;
41
42
```
42
43
43
44
``` js
44
45
// app.js
45
46
import ' custom.scss'
46
47
```
47
48
48
- Be sure to include your custom variables before ` bootstrap.scss ` and include BootstrapVue
49
- SCSS _ after_ Bootstrap SCSS to ensure variables are set up correctly.
49
+ Be sure to include your custom variables before ` bootstrap.scss ` and include BootstrapVue SCSS
50
+ _ after_ Bootstrap SCSS to ensure variables are set up correctly.
50
51
51
52
** Note** : _ Requires webpack configuration to load CSS/SCSS files
52
53
([ official guide] ( https://webpack.js.org/guides/asset-management/#loading-css ) )_ .
53
54
54
-
55
55
## Nuxt.js plugin module
56
56
57
57
Install dependencies:
@@ -74,20 +74,17 @@ This will include both `boostrap.css` and `bootstrap-vue.css` default CSS.
74
74
}
75
75
```
76
76
77
- If you are using custom Bootstrap SCSS, you can disable automatic inclusion of Bootstrap
78
- and BootstrapVue pre-compiled CSS files by setting the folliwing option(s) to ` false ` :
77
+ If you are using custom Bootstrap SCSS, you can disable automatic inclusion of Bootstrap and
78
+ BootstrapVue pre-compiled CSS files by setting the folliwing option(s) to ` false ` :
79
79
80
80
``` js
81
81
{
82
- modules: [
83
- [' bootstrap-vue/nuxt' , { bootstrapCss: false , bootstrapVueCss: false }],
84
- ]
82
+ modules: [[' bootstrap-vue/nuxt' , { bootstrapCss: false , bootstrapVueCss: false }]]
85
83
}
86
-
87
84
```
88
85
89
- BootstrapVue's custom CSS relies on some Boostrap SCSS variables. You can include Bootstrap
90
- and BootstrapVue SCSS in your project's custom SCSS file:
86
+ BootstrapVue's custom CSS relies on some Boostrap SCSS variables. You can include Bootstrap and
87
+ BootstrapVue SCSS in your project's custom SCSS file:
91
88
92
89
``` scss
93
90
// custom.scss
@@ -102,8 +99,8 @@ $grid-breakpoints: (
102
99
);
103
100
104
101
// Then include the following
105
- @include " bootstrap/scss/bootstrap" ;
106
- @include " bootstrap-vue/src/index.scss" ;
102
+ @include ' bootstrap/scss/bootstrap' ;
103
+ @include ' bootstrap-vue/src/index.scss' ;
107
104
```
108
105
109
106
In your app main entry point include the single custom SCSS file (when using ` sass-loader ` ):
@@ -113,13 +110,14 @@ In your app main entry point include the single custom SCSS file (when using `sa
113
110
import ' custom.scss'
114
111
```
115
112
116
-
117
113
## Vue CLI 2
118
114
119
115
BootstrapVue has two Vue CLI templates available:
120
116
121
- - [ webpack-simple] ( https://github.com/bootstrap-vue/webpack-simple ) : Quick scaffold for a proof of concept or small app
122
- - [ webpack] ( https://github.com/bootstrap-vue/webpack ) : Larger, production ready template with more options
117
+ - [ webpack-simple] ( https://github.com/bootstrap-vue/webpack-simple ) : Quick scaffold for a proof of
118
+ concept or small app
119
+ - [ webpack] ( https://github.com/bootstrap-vue/webpack ) : Larger, production ready template with more
120
+ options
123
121
124
122
``` bash
125
123
# Ensure Vue CLI is installed and up to date
@@ -141,7 +139,6 @@ npm run dev
141
139
You can repeat the commands above replacing ` bootstrap-vue/webpack-simple ` with
142
140
` bootstrap-vue/webpack ` for the webpack template.
143
141
144
-
145
142
## Vue CLI 3
146
143
147
144
Unlike V2, Vue CLI 3 doesn't use templates.
@@ -158,8 +155,8 @@ Enter the `my-project` directory and install `bootstrap-vue`:
158
155
npm i bootstrap-vue
159
156
```
160
157
161
- Under the hood, Vue CLI uses webpack, so we can register the BootstrapVue plugin
162
- as with the webpack instructions.
158
+ Under the hood, Vue CLI uses webpack, so we can register the BootstrapVue plugin as with the webpack
159
+ instructions.
163
160
164
161
``` js
165
162
import Vue from ' vue'
@@ -171,8 +168,9 @@ import 'bootstrap/dist/css/bootstrap.css'
171
168
import ' bootstrap-vue/dist/bootstrap-vue.css'
172
169
```
173
170
174
- Optionally, you can import components individually, as [ below] ( #individual-components-and-directives ) .
175
- To shorten import paths, we can add a webpack alias via ` vue.config.js ` .
171
+ Optionally, you can import components individually, as
172
+ [ below] ( #individual-components-and-directives ) . To shorten import paths, we can add a webpack alias
173
+ via ` vue.config.js ` .
176
174
177
175
``` js
178
176
const path = require (' path' )
@@ -181,25 +179,21 @@ module.exports = {
181
179
configureWebpack: {
182
180
resolve: {
183
181
alias: {
184
- ' bootstrap-components' : path .resolve (
185
- __dirname ,
186
- ' node_modules/bootstrap-vue/es/components'
187
- ),
182
+ ' bootstrap-components' : path .resolve (__dirname , ' node_modules/bootstrap-vue/es/components' )
188
183
}
189
184
}
190
185
}
191
186
}
192
187
```
193
188
194
- For additional configuration for Vue CLI 3 for using project relative paths for image src
195
- props on various BootstrapVue components, refer to the Vue CLI 3 section of the
189
+ For additional configuration for Vue CLI 3 for using project relative paths for image src props on
190
+ various BootstrapVue components, refer to the Vue CLI 3 section of the
196
191
[ Image Src Resolving] ( /docs/reference/images#vue-cli-3-support ) reference page.
197
192
198
-
199
193
## Individual components and directives
200
194
201
- If you would like to only pull in a specific component or set of components, you can do
202
- this by directly importing those components.
195
+ If you would like to only pull in a specific component or set of components, you can do this by
196
+ directly importing those components.
203
197
204
198
To cherry pick a component/directive, start by importing it in the file where it is being used:
205
199
@@ -232,11 +226,10 @@ Vue.directive('b-modal', BModalDirective)
232
226
Vue and ES2015 allow for various syntaxes here, so feel free to utilize kebab-casing (shown),
233
227
camelCasing, PascalCasing, and/or object property shorthand.
234
228
235
-
236
229
### Component groups and Directives as Vue plugins
237
230
238
- You can also import component groups and directives as Vue plugins by importing
239
- the component group or directive directory:
231
+ You can also import component groups and directives as Vue plugins by importing the component group
232
+ or directive directory:
240
233
241
234
``` js
242
235
// This imports all the layout components such as <b-container>, <b-row>, <b-col>:
@@ -256,17 +249,17 @@ import { Scrollspy } from 'bootstrap-vue/es/directives'
256
249
Vue .use (Scrollspy)
257
250
```
258
251
259
- When importing as plugins, all subcomponents and related directives are imported in most cases.
260
- i.e. When importing ` <b-nav> ` , all the ` <nav-*> ` sub components are also included, as well all
261
- dropdown sub components. Component shorthand aliases (if any) are also included in the plugin.
252
+ When importing as plugins, all subcomponents and related directives are imported in most cases. i.e.
253
+ When importing ` <b-nav> ` , all the ` <nav-*> ` sub components are also included, as well all dropdown
254
+ sub components. Component shorthand aliases (if any) are also included in the plugin.
262
255
263
256
Refer to the component and directive documentation for details.
264
257
265
258
### webpack + Babel
266
259
267
- When importing components/directives individually, you must configure your app to properly
268
- build the BootstrapVue library source code. This commonly involves white-listing the node
269
- module for your babel loader rule in webpack.
260
+ When importing components/directives individually, you must configure your app to properly build the
261
+ BootstrapVue library source code. This commonly involves white-listing the node module for your
262
+ babel loader rule in webpack.
270
263
271
264
``` js
272
265
// webpack.config.js
@@ -282,9 +275,10 @@ module.exports = {
282
275
rules: [
283
276
{
284
277
test: / \. js$ / ,
285
- include: [ // Use `include` vs `exclude` to whitelist vs blacklist
278
+ include: [
279
+ // Use `include` vs `exclude` to whitelist vs blacklist
286
280
path .resolve (__dirname , ' src' ), // Whitelist your app source files
287
- require .resolve (' bootstrap-vue' ), // Whitelist bootstrap-vue
281
+ require .resolve (' bootstrap-vue' ) // Whitelist bootstrap-vue
288
282
],
289
283
loader: ' babel-loader'
290
284
}
@@ -293,23 +287,26 @@ module.exports = {
293
287
}
294
288
```
295
289
296
-
297
290
## Browser
291
+
298
292
``` html
299
293
<!-- Add this to <head> -->
300
294
<link type =" text/css" rel =" stylesheet" href =" //unpkg.com/bootstrap/dist/css/bootstrap.min.css" />
301
- <link type =" text/css" rel =" stylesheet" href =" //unpkg.com/bootstrap-vue@latest/dist/bootstrap-vue.min.css" />
295
+ <link
296
+ type =" text/css"
297
+ rel =" stylesheet"
298
+ href =" //unpkg.com/bootstrap-vue@latest/dist/bootstrap-vue.min.css"
299
+ />
302
300
303
301
<script src =" //unpkg.com/@babel/polyfill@latest/dist/polyfill.min.js" ></script >
304
302
<script src =" //unpkg.com/vue@latest/dist/vue.min.js" ></script >
305
303
<script src =" //unpkg.com/bootstrap-vue@latest/dist/bootstrap-vue.min.js" ></script >
306
304
```
307
305
308
-
309
306
## Build Variants
310
307
311
- Choosing the best variant for your build environment / packager helps less bundle sizes.
312
- If your bundler supports es modules, it will automatically prefer it over commonjs.
308
+ Choosing the best variant for your build environment / packager helps less bundle sizes. If your
309
+ bundler supports es modules, it will automatically prefer it over commonjs.
313
310
314
311
| Variant | Environments | Package path |
315
312
| -------------- | --------------------- | ---------------------------------------------------------------------- |
@@ -318,38 +315,41 @@ If your bundler supports es modules, it will automatically prefer it over common
318
315
| commonjs2 | webpack 1 / ... | ` dist/bootstrap-vue.common.js ` _ or_ ` dist/bootstrap-vue.common.min.js ` |
319
316
| UMD | Browser | ` dist/bootstrap-vue.js ` _ or_ ` dist/bootstrap-vue.min.js ` |
320
317
321
-
322
318
## Migrating a project already using Bootstrap
323
319
324
- If you've already been using Bootstrap 4, there are a couple adjustments you may need to make to your project:
320
+ If you've already been using Bootstrap 4, there are a couple adjustments you may need to make to
321
+ your project:
325
322
326
323
- Remove the bootstrap.js file from your page scripts or build pipeline
327
- - If Bootstrap is the only thing relying on jQuery, you can safely remove it — BootstrapVue ** does not** depend on jQuery
324
+ - If Bootstrap is the only thing relying on jQuery, you can safely remove it — BootstrapVue ** does
325
+ not** depend on jQuery
328
326
- Convert your native Bootstrap HTML markup into the simplified BootstrapVue custom component markup
329
327
330
-
331
328
## Browser Support
332
329
333
330
### CSS
334
- BootstrapVue is to be used with Bootstrap 4 CSS/SCSS.
335
- Please see [ Browsers and devices] ( https://getbootstrap.com/docs/4.2/getting-started/browsers-devices )
336
- for more information about browsers currently supported by Bootstrap 4.
331
+
332
+ BootstrapVue is to be used with Bootstrap 4 CSS/SCSS. Please see
333
+ [ Browsers and devices] ( https://getbootstrap.com/docs/4.2/getting-started/browsers-devices ) for more
334
+ information about browsers currently supported by Bootstrap 4.
337
335
338
336
### JS
339
- BootstrapVue is written in Vue! So this is up to your project and bundler which browsers are supported.
337
+
338
+ BootstrapVue is written in Vue! So this is up to your project and bundler which browsers are
339
+ supported.
340
340
341
341
If you want to support older IE, Android and IOS devices, you may want to use
342
342
[ Babel Polyfill] ( https://babeljs.io/docs/usage/polyfill ) :
343
343
344
344
- ` npm install @babel/polyfill `
345
345
- Import it in your app main entry point with ` import '@babel/polyfill' `
346
346
347
-
348
347
## Tooling Support
349
348
350
349
### VS Code + Vetur
351
- If you are using [ VS Code] ( https://code.visualstudio.com/ ) as your text editor, BootstrapVue
352
- has intellisense autocompletion for component attributes available when using the
350
+
351
+ If you are using [ VS Code] ( https://code.visualstudio.com/ ) as your text editor, BootstrapVue has
352
+ intellisense autocompletion for component attributes available when using the
353
353
[ Vetur extension] ( https://marketplace.visualstudio.com/items?itemName=octref.vetur ) .
354
354
355
355
[ Twitter: Vetur + BootstrapVue] ( https://twitter.com/AlexSashaRegan/status/912769997776158723 )
0 commit comments