<style scoped src="~bootstrap/dist/css/bootstrap.css"></style>
<style scoped src="~bootstrap-vue/dist/bootstrap-vue.css"></style>
Important Update: Utilizing SCSS for a workaround
Here's the reason why the initial solution may not be effective:
When using scoped styles, the parent component's styles do not spill over to child components.
If you wish for a selector in scoped styles to have a "deep" impact on child components, you can employ the >>> combinator
as per the information provided in the Vue documentation on scoped CSS
The modal that was mentioned might not be controlled by the component where Bootstrap was imported. It could be within a child component or utilizing the jquery version of Bootstrap modal. Consequently, the data attributes will not be applied to the modal.
To address this issue, Deep Selector is required. (Further explanation can be found at )
Here's how I would incorporate the entire Bootstrap CSS using SCSS. (This task seems unfeasible solely with pure CSS.)
<template>
<div class="main-wrapper">
/* ... */
</div>
</template>
<style scoped lang="scss">
.main-wrapper /deep/ {
@import "~bootstrap/dist/css/bootstrap.min";
}
</style>
Some pre-processors like Sass may have difficulty parsing >>>
correctly. In such cases, you can resort to the /deep/ combinator instead -
it acts as an alias for >>> and functions identically.
The resulting CSS output will resemble
.main-wrapper[data-v-656039f0] .modal {
/* some css... */
}
.. which aligns with your objectives.
However, I must emphasize that importing the complete Bootstrap CSS is not recommended practice. It's preferable to import only the necessary parts from bootstrap-sass.
This approach may seem unconventional but is currently the most suitable option for your scenario.