我在我的Laravel 5.5和Vuejs 2项目中使用vue-toastr。
吐司正在正常显示,但我想全局为吐司设置一些选项,例如位置......
我做不到。
在我的应用程序中.js文件中,我从 vue-toastr 导入了 toastr,需要样式,然后Vue.component('vue-toastr', Toastr);
.
我已经在我的应用程序上尝试了this.$refs.toastr.defaultPosition = "toast-bottom-left"
.js就像文档所说的那样,但它给了我一个错误Cannot read property 'toastr' of undefined
有什么帮助吗?
如文档中所述:
添加组件 html:对于 vue 1.x
<vue-toastr v-ref:toastr></vue-toastr>
添加组件 html:对于 vue 2.x
<vue-toastr ref="toastr"></vue-toastr>
然后你可以使用
this.$refs.toastr.defaultPosition = "toast-bottom-left"