This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<template> | |
<div> | |
<span>{{ nr }}</span> | |
<div> | |
</template> | |
<script> | |
export default { | |
data() { | |
return { nr: 0 }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Vue.component('Counter', { | |
// define the template in the component | |
// or reference a template defined in the DOM | |
template: ` | |
<div> | |
<span>{{ nr }}</span> | |
<div> | |
`, | |
// internal state (aka. viewmodel) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<template> | |
<input v-model="name" /> | |
</template> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let { items } = this.props; | |
let children; | |
if (items.length > 0) { | |
children = ( | |
<ul> | |
{items.map(item => | |
<li key={item.id}>{item.name}</li> | |
)} | |
</ul> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// JSX: using {" "} to add whitespace | |
<div> | |
<b>1</b> | |
{" "} | |
<b>2</b> | |
</div> | |
// Vue renders as expected | |
<div> | |
<b>1</b> |
NewerOlder