[Vuejs]-Laravel eloquent data or simple props to create a custom Vue-router link in Vue.Js

0👍

Fixed by my own: https://jsfiddle.net/uncoke/92x0jhr1/

Here my own fix:

The custom data with link:

    { team: "<a href=\"/club/"+team.id+"\" data-to='{\"name\": \"team\",\"params\":{\"teamId\":"+ team.id+"}}'>"+ team.team+"</a> "+userCode,
 ....}

The click Listener

mounted() {
        window.addEventListener('click', event => {
            let target = event.target;
            if (target && target.href && target.dataset.to) {
                event.preventDefault();
                const url = JSON.parse(target.dataset.to);
                //router.push({ name: 'user', params: { userId: '123' } })
                this.$router.push(url);
            }
        });
    }

Leave a comment