How to use this.$inertia?
Closed this issue · 3 comments
Hi, these are class-based components based on Vue Property Decorator, things here are different with it https://github.com/kaorun343/vue-property-decorator, also about intertia docs are outdated on some level to access it it is different this.$parent and then you can get intertia, but My advice is to watch these series to grasp the concept https://laracasts.com/series/build-modern-laravel-apps-using-inertia-js.
Post Scriptum,
Oskars,
Template part hasn't changed also, My advice look at pingcrm as concept of it to make more sense on how thing's works https://github.com/inertiajs/pingcrm
Sample of Class-Based component with working Intertia sample.
<script lang='ts'>
import { Component, Prop, Vue } from 'vue-property-decorator';
import { Inertia, RequestPayload } from '@inertiajs/inertia';
@Component({ name: 'LoginIndex' })
export default class Index extends Vue {
@Prop({ default: null })
private auth: any;
@Prop({ default: null })
private flash: any;
@Prop({ default: null })
private errors: any;
private route: any;
private form: Object = {
email: null,
password: null,
game_key: null,
remember: false,
};
private login() {
Inertia.post(this.route('en.login'), <RequestPayload>this.form);
}
}
</script>
I hope it helps.
Post Scriptum,
Oskars.
Pretty good, it helped me a lot! Thanks!