VueJs-#10 Bootstrap-Vue

BootstrapVue dibuat berdasarkan template yang paling populer di dunia yaitu Bootstrap v4, untuk membangun situs yang responsif menggunakan Vue.js.


  1. Buat Project Menggunakan Vue CLI

Kita angap nama Project ini adalah learning-vue-bootstrap. Masuk ke direktori project:

Install BootstrapVue.

cd learning-vue-bootstrap
vue add bootstrap-vue

Install Vue Router

npm install vue-router

Buat file src/router/index.js

import Vue from 'vue'
import Router from 'vue-router'
import HelloWorld from "@/components/HelloWorld"
import Home from "@/components/Home"
import About from "@/components/About";


export default new Router({
  routes: [
      path: '/',
      name: 'Welcome',
      component: HelloWorld
      path: '/Home',
      name: 'Home',
      component: Home
      path: "/about",
      name: "About",
      component: About

Karena kita menggunakan router, maka kita harus mengimport router pada src/main.js

import '@babel/polyfill'
import 'mutationobserver-shim'
import Vue from 'vue'
import './plugins/bootstrap-vue'
import App from './App.vue'
import router from './router'

Vue.config.productionTip = false

new Vue({
  render: h => h(App),

Kita lihat di index.js ada dua komponen tambahan yaitu Home & About. Kita buat kedua komponen ini


    <div class="home">
        <b-jumbotron header="HOME" lead="">
            <p><strong>{{title}}</strong> Lorem Ipsum is simply dummy text of the printing and typesetting industry.
            Lorem Ipsum has been the industry's standard dummy text ever since the 1500s,
            when an unknown printer took a galley of type and scrambled it to make a type specimen book.
            It has survived not only five centuries, but also the leap into electronic typesetting,
            remaining essentially unchanged.
            It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages,
            and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.</p>
export default {
  data() {
      return {
          title: 'Halaman Utama'


    <div class="about">
        <b-jumbotron header="ABOUT US" lead="">
            <p><strong>{{title}}</strong> It is a long established fact that a reader will be distracted by the readable content of a page
            when looking at its layout. The point of using Lorem Ipsum is that it has a more-or-less normal
            distribution of letters, as opposed to using 'Content here, content here',
            making it look like readable English. Many desktop publishing packages and
            web page editors now use Lorem Ipsum as their default model text, and a search
            for 'lorem ipsum' will uncover many web sites still in their infancy.
            Various versions have evolved over the years,
            sometimes by accident, sometimes on purpose (injected humour and the like).</p>
export default {
  data() {
      return {
          title: 'Tentang Kami'

Sekarang kita tambahkan navigasi pada src/App.vue

  <div id="app">
      <b-navbar toggleable="lg" type="dark" variant="info">
        <b-navbar-brand href="#">NavBar</b-navbar-brand>
        <b-navbar-toggle target="nav-collapse"></b-navbar-toggle>
        <b-collapse id="nav-collapse" is-nav>
            <b-nav-item to="/Home">Home</b-nav-item>
            <b-nav-item to="About">About</b-nav-item>
            <b-nav-item to="#" disabled>Disabled</b-nav-item>
          <!-- Right aligned nav items -->
          <b-navbar-nav class="ml-auto">
              <b-form-input size="sm" class="mr-sm-2" placeholder="Search"></b-form-input>
              <b-button size="sm" class="my-2 my-sm-0" type="submit">Search</b-button>
            <b-nav-item-dropdown text="Lang" right>
              <b-dropdown-item href="#">EN</b-dropdown-item>
              <b-dropdown-item href="#">ES</b-dropdown-item>
              <b-dropdown-item href="#">RU</b-dropdown-item>
              <b-dropdown-item href="#">FA</b-dropdown-item>
            <b-nav-item-dropdown right>
              <!-- Using 'button-content' slot -->
              <template v-slot:button-content>
              <b-dropdown-item href="#">Profile</b-dropdown-item>
              <b-dropdown-item href="#">Sign Out</b-dropdown-item>
    <div class="container mt-2">


export default {

#app {
  font-family: 'Avenir', Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-align: center;
  color: #2c3e50;
  /*margin-top: 60px;*/

Jalankan Program

Menu Home
npm run serve

Lalu buka browser http://localhost:8080/#/Home

Cantik bukan tampilannya. Untuk mempelajari komponen BootstrapVue silakan kunjungi halamannya di

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes:

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>