Add link to a button in Vue Button component

11 Jun 20241 minute to read

The appearance of the Button can be changed like a link by e-link class using cssClass property and link navigation can be handled in Button click.

In the following example, link is added in Button click by using window.open() method.

<template>
<ejs-button cssClass='e-link' v-on:click='btnClick'>Button</ejs-button>
</template>
<script setup>
import { ButtonComponent as EjsButton } from '@syncfusion/ej2-vue-buttons';
import { enableRipple } from '@syncfusion/ej2-base';
enableRipple(true);
const btnClick = function(event) {
    window.open("https://www.google.com");
    }
</script>
<style>
@import '../node_modules/@syncfusion/ej2-base/styles/material.css';
@import '../node_modules/@syncfusion/ej2-buttons/styles/material.css';
button {
  margin: 25px 5px 20px 20px;
}
</style>
<template>
<ejs-button cssClass='e-link' v-on:click='btnClick'>Button</ejs-button>
</template>
<script>
import { ButtonComponent } from '@syncfusion/ej2-vue-buttons';
import { enableRipple } from '@syncfusion/ej2-base';
enableRipple(true);
export default {
name: "App",
components: {
"ejs-button":ButtonComponent
},
    methods : {
        btnClick: function(event) {
            window.open("https://www.google.com");
        }
    }
}
</script>
<style>
@import '../node_modules/@syncfusion/ej2-base/styles/material.css';
@import '../node_modules/@syncfusion/ej2-buttons/styles/material.css';
button {
  margin: 25px 5px 20px 20px;
}
</style>