<script setup>
/***
 * name：路由Query参数 示例
 * user：sa0ChunLuyu
 * date：2022-04-13 09:20:12
 */
import $router from '~/router'
import {onBeforeRouteUpdate} from "vue-router";

const default_page_options = {
  name: '鹿和'
}
const page_options = ref(JSON.parse(JSON.stringify(default_page_options)))
onBeforeRouteUpdate((to) => {
  routerChange(to.query)
})

const routerChange = (query) => {
  page_options.value = {
    name: query.name || default_page_options.name
  }
}

onMounted(() => {
  routerChange($router.currentRoute.value.query)
})
</script>
<template>
  <tr>
    <td>Query</td>
    <td>{{ JSON.stringify(page_options) }}</td>
    <td></td>
  </tr>
</template>
