Vue + Typescript で画面遷移時のイベントを取得する方法
<script lang="ts"> import { Component, Vue } from 'vue-property-decorator' import VueRouter from 'vue-router' Component.registerHooks(['beforeRouteLeave']) @Component({ components: {} }) export default class AccountAdd extends Vue { private beforeRouteLeave(to: VueRouter, from: VueRouter, next: any) { window.confirm('このページから移動しますか?登録中のデータは保存されません') ? next() : next(false) } } </script>