当我登录应用程序并选择编辑某个项目时,他们将 $router.push 发送到编辑视图,问题是他们渲染了组件两次,我通过在 mount(){ 上执行 console.log 来解决这个问题} .. 但是,如果我重新加载页面并在其他时间单击编辑,它们只会正确渲染一次。
这是相关代码:
//listItemsView script
editItem(item) {
this.$router.push({ name: 'editPolicy', params:{policyTest: item}})
},
//editItemView script
export default {
props:{
policyTest:{
type: Object,
required: true,
}
mounted(){
console.log(this.policyTest);
console.log('entra');
},
}
Run Code Online (Sandbox Code Playgroud)
//router script
{
path: '/editPolicy/',
name: 'editPolicy',
component: () => import('../views/policies/editPolicy.vue'),
props: true,
meta:{requireAuth:true}
}
router.beforeEach((to, from, next) => {
const user = auth.currentUser;
if(user !== null){
user.getIdTokenResult(true)
.then(function ({
claims
}) {
if (to.name === 'NewClient' && !claims.permissions.includes('Agregar Cliente')) {
next({name: 'notFoundPage'}); …Run Code Online (Sandbox Code Playgroud)