Skip to content

Instantly share code, notes, and snippets.

@newbornfrontender
Created October 16, 2018 11:20
Show Gist options
  • Save newbornfrontender/254c165b3fc6938e4374de3015e148ef to your computer and use it in GitHub Desktop.
Save newbornfrontender/254c165b3fc6938e4374de3015e148ef to your computer and use it in GitHub Desktop.
Vue accessibility (vue-announcer)
<template>
<div class="about">
<h1>This is an about page</h1>
</div>
</template>
<script>
export default {
mounted() {
setTimeout(() => {
this.$announcer.set('Notification: A surprising announcement!')
}, 10000)
}
}
</script>
<template>
<div id="app">
<vue-announcer data-va="announcer" />
<div id="nav">
<router-link
to="/"
title="Go to home page (title)"
aria-label="Go to home page (aria)"
>Home</router-link> |
<router-link
to="/about"
title="Go to about page (title)"
aria-label="Go to about page (aria)"
>About</router-link>
</div>
<router-view/>
</div>
</template>
<style>
#app {
font-family: "Avenir", Helvetica, Arial, sans-serif;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
text-align: center;
color: #2c3e50;
}
#nav {
padding: 30px;
}
#nav a {
font-weight: bold;
color: #2c3e50;
}
#nav a.router-link-exact-active {
color: #42b983;
}
</style>
import Vue from "vue";
import App from "./App.vue";
import router from "./router";
import VueAnnouncer from "vue-announcer";
Vue.config.productionTip = false;
Vue.use(VueAnnouncer, {
complementRoute: "is ready!",
}, router);
new Vue({
router,
render: h => h(App)
}).$mount("#app");
import Vue from "vue";
import Router from "vue-router";
import Home from "./views/Home.vue";
Vue.use(Router);
export default new Router({
mode: "history",
base: process.env.BASE_URL,
routes: [
{
path: "/",
name: "home",
component: Home,
meta: {
announcer: "Home route"
}
},
{
path: "/about",
name: "about",
component: () =>
import(/* webpackChunkName: "about" */ "./views/About.vue"),
meta: {
announcer: "About route"
}
}
]
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment