$bvToast not getting injected into vue component object
See original GitHub issueHello, thank you for your work, really appreciate. I have difficulties to manage toast via vue component methods because I am not getting injected $bvToast object.
Describe the bug
$bvToast not getting injected into component
Error:
[Vue warn]: Error in v-on handler: "TypeError: Cannot read property 'hide' of undefined"
Steps to reproduce the bug
- Go to https://codesandbox.io/embed/bootstrap-vue-missing-bvtoast-j3umo
- Click on button
- See error in console
Expected behavior
Closing opened toast
Versions
Libraries:
- BootstrapVue: 2.0.0.rc27
- Bootstrap: 4.3.1
- Vue: 2.5.22
Environment:
online editor
Demo link
https://codesandbox.io/embed/bootstrap-vue-missing-bvtoast-j3umo
Thank you very much! 😃
Issue Analytics
- State:
- Created 4 years ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
How to access $bvToast in vue class component
$bvToast is not available directly. There is a workaround however to access the main Vue instance within VueX. Use this._vm.$bvToast instead.
Read more >Toast | Components - BootstrapVue
A new $bvToast injection (mixin) is created for each Vue virtual machine instance (i.e. each instantiated component), and is not usable via direct...
Read more >Is there a way to show a bootstrap-vue $toast feedback in ...
Coding example for the question Is there a way to show a bootstrap-vue $toast feedback in beforeRouteEnter?-Vue.js.
Read more >bootstrap-vue - UNPKG
node_modules/core-js/library/modules/_to-object.js",". ... Vue\n//\nimport Vue from 'vue'\n\nexport default Vue\n","/**\n * Utilities to get information ...
Read more >A Light, easy and beautiful Toast - Vue.js Examples
Then get access to the toast interface on your components with useToast : ... was passed, not as an object but as //...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
You can only pass one plugin to
Vue.use(...)
at a time. You need toVue.use(...)
each plugin on a separate line.Vue.use(...)
interprets the second argument as a configuration object to pass to the plugin, and ignores the 3rd argument onwards.When you do this:
Vue installs
LayoutPlugin
only, and attempts to pass the second argument (ModalPlugin
) as a configuration object toLayoutPlugin
, which of course it is not a configuration object.Each plugin has an
install
method which Vue calls to install the plugin. This is why you are seeing the"unknown config property 'install'"
warning.This is the correct way:
If you are including the
ModalPlugin
, it automatically includes theBVModalPlugin
. Similarly forToastPlugin
which automatically includesBVToastPlugin
.I’ve tried the above, but it’s still not injecting the toast component. I’m using
"bootstrap-vue": "^2.0.0-rc.27"
toomain.js
fileinside
methods
in my view, I’m calling it like so:Inside my console, I’m seeing this error:
warn.js?686b:11 [BootstrapVue warn]: config: unknown config property "install"
Stack expands to:
Inside
mounted
when I try to print thebvToast
object, it simply returnsundefined
in my console:Can’t seem to figure out where I’ve gone wrong. Would sincerely appreciate any ideas