ReferenceError: bootstrap is not defined · Discussion #31239
文章推薦指數: 80 %
Open modal programmatically - ReferenceError: bootstrap is not defined. ... I'm importing in the main.js file of my vue app the bootstrap.min.js file using ...
Skiptocontent
{{message}}
twbs
/
bootstrap
Public
Notifications
Fork
76.3k
Star
156k
Code
Issues
318
Pullrequests
113
Discussions
Actions
Projects
7
Security
Insights
More
Code
Issues
Pullrequests
Discussions
Actions
Projects
Security
Insights
Openmodalprogrammatically-ReferenceError:bootstrapisnotdefined
#31239
Answered
by
Johann-S
realrecordzLab
askedthisquestionin
General
Openmodalprogrammatically-ReferenceError:bootstrapisnotdefined
#31239
realrecordzLab
Jul4,2020
·
5answers
·
3replies
Answered
by
Johann-S
Returntotop
realrecordzLab
Jul4,2020
I'musingbootstrapv5inmyvueapp.I'mimportingthecssanditworksfine.
Iwanttousethemodalcomponentandopenitprogrammatically.I'mimportinginthemain.jsfileofmyvueappthebootstrap.min.jsfileusingthissyntax:import'bootstrap/dist/js/bootstrap.min.js'andinmymethodsI'vecreatedafunctionthathavethiscode:
showTableData(){
letdate=newDate().toLocaleDateString()
letdataExportModal=newbootstrap.Modal(document.getElementById('myModal'))
dataExportModal.show()
}
WhatishappeningisthatIgetthiserrorinconsolewhenIclickonthebuttonthatwillusethefunction:ReferenceError:bootstrapisnotdefined
I'mnotsureonwhat'swrongwiththecode,butanyhelpwillbeappreciated.
1
Answeredby
Johann-S
Jul5,2020
AsimpleBootstrap5+Vue.jsproject:https://stackblitz.com/edit/bootstrap5-vuejs
enjoy😉
Viewfullanswer
Replies
5suggestedanswers
·
3replies
Oldest
Newest
Top
edited
Johann-S
Jul5,2020
Collaborator
Hi@realrecordzLab,
ThereareseveralwaytoimportBootstrap.Ifyou'reusingVue.jsIassumeyouhaveaWebpackbundlerunderthehood.
SoyoucanimportourModalcomponentlikethat:
import{Modal}from'bootstrap'
orifyouwanttoimporteverythingyoucando:
import*asBootstrapfrom'bootstrap'
2
👍
5
0replies
realrecordzLab
Jul5,2020
Author
I'vetriedtoimportonlythemodalcomponentbutIgeta`bootstrapisnot
defined`error.I'musingthemodalinsideacomponent,triedtoimportthe
bsjavascriptalsotherebutsameproblem,Idon'tknowwhat'swrong,but
I'mstartthinkingthatit'sabugofthenewversionofbootstrap?
1
👍
3
1reply
DeoThemes
Feb10,2021
I'mhavingthesameissue.Didyoufindsolution?
👍
1
Johann-S
Jul5,2020
Collaborator
AsimpleBootstrap5+Vue.jsproject:https://stackblitz.com/edit/bootstrap5-vuejs
enjoy😉
Markedasanswer
2
🎉
2
❤️
2
2replies
realrecordzLab
Jul5,2020
Author
Iwilltakealook,I'monsinglefilecomponentsbutIwillgiveanewtrytotheimportasyou'vesuggested!
AshutoshSharma7
Jul15,2021
HeyGuyz,
Ifoundthesolutionafteralotofstruggle.
Addinapplication.js
window.bootstrap=require('bootstrap/dist/js/bootstrap.bundle.js')
afterthis"`bootstrapisnotdefined"IS
Ex
import'bootstrap'
require("@rails/ujs").start()
require("turbolinks").start()
require("@rails/activestorage").start()
require("channels")
window.bootstrap=require('bootstrap/dist/js/bootstrap.bundle.js')
AnswerselectedbyJohann-S
AshutoshSharma7
Jul15,2021
HeyGuyz,
Ifoundthesolutionafteralotofstruggle.
Addinapplication.js
window.bootstrap=require('bootstrap/dist/js/bootstrap.bundle.js')
afterthis"`bootstrapisnotdefined"IS
Ex
import'bootstrap'
require("@rails/ujs").start()
require("turbolinks").start()
require("@rails/activestorage").start()
require("channels")
window.bootstrap=require('bootstrap/dist/js/bootstrap.bundle.js')
3
👍
1
0replies
deepakmahakale
Aug31,2021
Justreplacethefollowinginapp/javascript/packs/application.js
require("bootstrap")
with
window.bootstrap=require("bootstrap")
workedformeinrails6+webpacker+bootstrap5
3
👍
2
0replies
Signupforfree
tojointhisconversationonGitHub.
Alreadyhaveanaccount?
Signintocomment
Category
#️⃣
General
Labels
Noneyet
5participants
Addheadingtext
Addboldtext,
延伸文章資訊
- 1Introduction - React-Bootstrap
Learn how to include React Bootstrap in your project. Installation#. The best way to consume Reac...
- 2Tab components - React-Bootstrap
From an accessibility point of view, there is currently no sensible way to map this sort of const...
- 3React Bootstrap fails to render - Stack Overflow
I downdloaded React Bootstrap and already included it in HTML file. This is impossible! javascrip...
- 4Using Bootstrap with React - LogRocket Blog
You can use Bootstrap directly on elements and components in your React app by applying the built...
- 5'ReactBootstrap' is not defined Code Example
“'ReactBootstrap' is not defined” Code Answer. install react bootstrap. shell by Th3 K3oS on Oct ...