Skip to content

Instantly share code, notes, and snippets.

<template>
<div>
<GlobalEvents
@focus="handleAppFocus"
></GlobalEvents>
<!-- Component Contents -->
</div>
</template>
<script>
// Register a global custom directive called `v-focus`
Vue.directive('focus', {
// When the bound element is inserted into the DOM...
inserted: function (el) {
// Focus the element
el.focus()
}
})
router.beforeEach((to, from, next) => {
document.title = to.meta.title
next()
})
const routes = [
{
path: '/',
component: App,
meta: {
title: 'My Website- Homepage'
}
},
{
path: '/contact',
let node = {
tag: 'div'
attributes: { id: 'container' }
children: [
// where the contained div would go
]
};
<div id='container'>
<div id='baby'>
Hello
</div>
</div>
@emilyruby
emilyruby / title_example.jsx
Last active January 4, 2018 17:57
This is the example from the react-document-title readme. https://github.com/gaearon/react-document-title
function App() {
// Use "My Web App" if no child overrides this
return (
<DocumentTitle title='My Web App'>
<SomeRouter />
</DocumentTitle>
);
}
function HomePage() {
<ul>
<li>Hello</li>
<li>World</li>
</ul>
class List extends React.Component {
render() {
return (
<ul>
<ListItem />
</ul>
);
}
}
<ul>
<div>
<li>Hello</li>
<li>World</li>
</div>
</ul>