import { CreateElement , VNode } from 'vue/types/index' ; import { RawLocation } from 'vue-router' ; const AccessRouterLink = { name : 'AccessRouterLink' , extends : 'router-link' , data ( ) { return { hasPermission : true , } ; } , render ( createElement ) { return ( this . hasPermission as boolean ) ? createElement ( 'router-link' , { props : this . _props , } , this . $slots . default ) : null ; } , watch : { '$access.accessData.userOptions' : { handler ( ) { this . initPermission ( ) ; } , deep : true , } , } , methods : { initPermission ( ) { const router = this . $router ; let access = this . $access ; access . isCanTo ( router , this . to as RawLocation , this . $route , this . append as boolean ) . then ( ( result ) => ( this . hasPermission = result ) ) ; } , } , mounted ( ) { this . initPermission ( ) ; } , } ; export default AccessRouterLink ;