1

I am developing a small VueJS app, similar to a calculator, that will be mounted to a DOM element within an existing "static" page on a Bootstrap 4 themed CMS. The nav bar and other site functionality all relies on vanilla Bootstrap 4 CSS/JS. There will not be any DOM interaction between the non-Vue and Vue portions of the page. The non-Vue portions are simple content and navigation.

Currently, without using Bootstrap-Vue, everything is working fine.

I would like to use Bootstrap-Vue components within the VueJS managed portions of the page. According to those components' docs:

If you've already been using Bootstrap 4, there are a couple adjustments you may need to make to your project: [1] Remove the bootstrap.js file from your page scripts or build pipeline, [2]...

Since the non-Vue portions of the page use bootstrap.js, can I simply include both the bootstrap.js as well as the bootstrap-vue.js libraries at runtime? Any issues I should be aware of?

1 Answer 1

1

In the following example i have used two part one is specified to Vue and another one for bootstrap only.

I'm providing the following simplified example to show you how to do that

new Vue({
  el: '#app',

  data() {
    return {
    item:'',
     currentPassword:'',
     req:false
    }
  },
  methods: {
  changePassword: function() {
    this.req=true;
    }
  }

});
<link type="text/css" rel="stylesheet" href="//unpkg.com/bootstrap/dist/css/bootstrap.min.css" />
<link type="text/css" rel="stylesheet" href="//unpkg.com/bootstrap-vue@latest/dist/bootstrap-vue.css" />

<!-- Add this after vue.js -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.5.16/vue.js"></script>
<script src="//unpkg.com/babel-polyfill@latest/dist/polyfill.min.js"></script>
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.3/umd/popper.min.js" integrity="sha384-ZMP7rVo3mIykV+2+9J3UJ46jBk0WLaUAdn689aCwoqbBJiSnjAK/l8WvCWPIPm49" crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.min.js" integrity="sha384-ChfqqxuZUCnJSK3+MXmPNIyE6ZbWh2IMqE241rYiqJxyMiZ6OW/JmZQ5stwEULTy" crossorigin="anonymous"></script>
<script src="//unpkg.com/bootstrap-vue@latest/dist/bootstrap-vue.js"></script>

<body>
<div id="outOfVue">
<p>
  <a class="btn btn-primary" data-toggle="collapse" href="#collapseExample" role="button" aria-expanded="false" aria-controls="collapseExample">
    Link with href
  </a>
  <button class="btn btn-primary" type="button" data-toggle="collapse" data-target="#collapseExample" aria-expanded="false" aria-controls="collapseExample">
    Button with data-target
  </button>
</p>
<div class="collapse" id="collapseExample">
  <div class="card card-body">
    Anim pariatur cliche reprehenderit, enim eiusmod high life accusamus terry richardson ad squid. Nihil anim keffiyeh helvetica, craft beer labore wes anderson cred nesciunt sapiente ea proident.
  </div>
</div>
</div>
<div id="app" class="container">
  <div>
    
    <b-form validated="" id="passwordChangeForm" @submit.prevent="changePassword" class="container-fluid">
      <b-form-group id="currentPassword" label="Old password">
        <b-form-input id="password" v-model="currentPassword" placeholder="Enter your old Password" type="password" :required="req" />
      </b-form-group>
      <b-button type="submit" variant="primary">Submit</b-button>
    </b-form>
  </div>
</div>
</body>

Sign up to request clarification or add additional context in comments.

1 Comment

The example is very helpful. This is exactly what I needed. I can now piece together pages using the CMS backend and they will be able to work together.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.