Skip to content

Instantly share code, notes, and snippets.

@lamnd
lamnd / sprintf.js
Created November 29, 2019 03:07 — forked from rmariuzzo/sprintf.js
Simple and minimal `sprintf` function in JavaScript.
function sprintf(format) {
var args = Array.prototype.slice.call(arguments, 1);
var i = 0;
return format.replace(/%s/g, function() {
return args[i++];
});
}
@lamnd
lamnd / childA.vue
Last active June 6, 2019 08:35
Child A - no remcomend
<template>
<div id="child-a">
<h2>Child A</h2>
<pre>data {{ this.$data }}</pre>
<hr/>
<button @click="changeScore">Change Score</button>
<span>Score: {{ score }}</span>
</div>
</template>
@lamnd
lamnd / index.js
Created June 6, 2019 08:02
Index of Router
import Vue from 'vue'
import Router from 'vue-router'
import ParentA from '@/components/ParentA'
Vue.use(Router)
export default new Router({
routes: [
{
path: '/',
@lamnd
lamnd / childB.vue
Created June 6, 2019 08:00
Child B
<template>
<div id="child-b">
<h2>Child B</h2>
<pre>data {{ this.$data }}</pre>
<hr/>
<span> Show Score: {{ score }}</span>
</div>
</template>
<script>
@lamnd
lamnd / childA.vue
Last active June 6, 2019 08:41
Child A
<template>
<div id="child-a">
<h2>Child A</h2>
<pre>data {{ this.$data }}</pre>
<hr/>
<button @click="changeScore">Change Score</button>
<span>Score: {{ localScore }}</span>
</div>
</template>
@lamnd
lamnd / parentA.vue
Last active June 6, 2019 08:43
Parent A
<template>
<div id="parent-a">
<h2>Parent A</h2>
<pre>data {{ this.$data }}</pre>
<button @click="reRender">Rerender Parent</button>
<hr/>
<child-a :score="score" @updateScore="updateScore"/>
<child-b :score="score"/>
</div>
</template>