我正在使用inertial .js创建一个页面。当我在Vue模板文件中添加Vue -toastr时,它不起作用。我不知道怎么修理它。请推荐我
这是app.js
import Vue from 'vue'
import { createInertiaApp } from '@inertiajs/inertia-vue'
import Toastr from 'vue-toastr'
Vue.use(Toastr);
createInertiaApp({
resolve: name => require(`./Pages/${name}`),
setup({ el, App, props }) {
new Vue({
render: h => h(App, props),
}).$mount(el)
},
})
这是我们的模板文件
<script>
import Master from './Layout/Master';
export default{
name:"Home",
created(){
this.$toastr.s("success","it is working");
},
components:{Master}
};
</script>
use
the import Toastr from 'vue-toastr'
directly on your vue instance not in app.js like this :
<script>
import Master from './Layout/Master';
import Toastr from 'vue-toastr'
export default{
name:"Home",
data()
{
return
{
toastr: Toastr
}
}
,
created(){
this.$toastr.s("success","it is working");
},
components:{Master}
};
</script>