Upgranding Inertia and Inertia Vue #791
Answered
by
lucraraujo
lucraraujo
asked this question in
Help
-
I'm upgrading from inertia version 0.5.x and inertia-vue version 0.8.x to latest (0.6.2 and 0.9.2 as of this date) and I'm having some trouble with the instance factory. I use a Buefy notification to show errors to the user and I made it permanent in the Vue constructor, but a I don't know where I can do the same thing using the factory, Here's my current app.js file: import BuefyOptions from './buefyOptions'
import Favicon from '@@/icons/Simbolo.svg'
import Layout from '@/Shared/Layout.vue'
import Vue from 'vue'
import VueMeta from 'vue-meta'
import Buefy, { NotificationProgrammatic as BNotification, LoadingProgrammatic as BLoading } from 'buefy'
import { App, plugin as InertiaVue } from '@inertiajs/inertia-vue'
import { Inertia } from '@inertiajs/inertia'
Vue.use(Buefy, BuefyOptions)
Vue.use(InertiaVue)
Vue.use(VueMeta)
Vue.mixin({ methods: { route } })
const el = document.getElementById('app')
let loading = null
Inertia.on('start', () => {
const loadingElement = document.getElementById('loading')
loading = BLoading.open({ container: loadingElement })
})
Inertia.on('finish', () => {
loading.close()
})
new Vue({
metaInfo: {
titleTemplate: (title) => title ? `${title} - CRH-e` : 'CRH-e',
link: [
{ rel: 'icon', href: Favicon }
]
},
render: h => h(App, {
props: {
initialPage: JSON.parse(el.dataset.page),
resolveComponent: name => import(`./Pages/${name}.vue`)
.then(({ default: page }) => {
page.layout = page.layout === undefined ? Layout : page.layout
return page
}),
resolveErrors: (page) => {
for (const error in page.props.errors) {
BNotification.open({
message: page.props.errors[error],
type: 'is-danger',
position: 'is-bottom-right',
queue: false,
closable: true,
indefinite: true
})
}
return page.props.errors || {}
}
}
})
}).$mount(el) Thank you! |
Beta Was this translation helpful? Give feedback.
Answered by
lucraraujo
Jul 6, 2021
Replies: 1 comment
-
Solved! import Vue from 'vue'
import Buefy, { NotificationProgrammatic as BNotification } from 'buefy'
import { createInertiaApp } from '@inertiajs/inertia-vue'
import { Inertia } from '@inertiajs/inertia'
Vue.use(Buefy,)
Inertia.on('error', (errors) => {
for (const error in errors.detail.errors) {
BNotification.open({
message: errors.detail.errors[error],
type: 'is-danger',
position: 'is-bottom-right',
queue: false,
closable: true,
indefinite: true
})
}
})
createInertiaApp({
resolve: name => import(`./Pages/${name}.vue`),
setup ({ el, app, props }) {
new Vue({
render: h => h(app, props)
}).$mount(el)
}
}) |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
lucraraujo
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Solved!
After reading the documentation, I solved the problem by using the error event.