之前因为在同一个页面里面,需要用两个 script,而其中有个没有加 name ,导致一直缓存不成功,在此记录一下。
贴个官网地址:前端手册 | RuoYi
代码:
router - index.js
// router.js
...
// 采购管理
{
path: "/purchase",
component: Layout,
hidden: true,
children: [
{
path: "order/edit",
component: () => import("@/views/purchase/order/edit"),
// 注意此处的name需要与组件的name保持完全一致
name: "PurchaseOrderEdit",
meta: { title: "新增备货订单", icon: "" },
},
......
]
}
页面 views/purchase/order/edit
<script>
import {defineComponent} from "vue";
export default defineComponent({
// 这里需要加 name
name:'PurchaseOrderEdit',
beforeRouteEnter(to, from, next) {
if (to.query.type == 'fix') {
to.meta.title = '修改采购订单'
} else {
to.meta.title = '新增备货订单'
}
next();
}
})
</script>
<script setup name="PurchaseOrderEdit">
......
</script>