This file contains 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
function assert (actual) { | |
return { | |
equals (expected) { | |
if (actual !== expected) { | |
throw new Error(`${actual} is not equal to ${expected}`) | |
} | |
console.log(`${actual} equals ${expected}`) | |
} | |
} | |
} |
This file contains 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
function apiRequest({ | |
endpoint, | |
method = 'GET', | |
getParams = {}, | |
headers = ['Content-Type: text-plain'], | |
callback = () => {}, | |
timeout = 0, | |
authRequest = true, | |
} = {}) { | |
//... |
This file contains 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
apiRequest({ // notice the curly braces! we are passing an object now | |
endpoint: 'products', | |
method: 'GET', | |
getParams: { category: 3 }, | |
headers: ["Content-Type: text/plain"], | |
callback: function(response) {}, | |
timeout: 0, | |
authRequest: true | |
}) |
This file contains 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> | |
<h1>Election day!</h1> | |
<button @click="voteForRed">Vote for 🔴</button> | |
<button @click="voteForBlue">Vote for 🔵</button> | |
<h2>Results</h2> | |
<results/> | |
<total-votes/> | |
</div> |
This file contains 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
<script> | |
import Vue from 'vue' | |
const state = new Vue({ | |
data () { | |
return { red: 0, blue: 0 } | |
}, | |
methods: { | |
voteForRed () { this.red++ }, | |
voteForBlue () { this.blue++ }, |
This file contains 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> | |
<h1>Election day!</h1> | |
<button @click="voteForRed">Vote for 🔴</button> | |
<button @click="voteForBlue">Vote for 🔵</button> | |
<h2>Results</h2> | |
<results/> | |
<total-votes/> | |
</div> |
This file contains 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> | |
<h1>Election day!</h1> | |
<button @click="voteForRed">Vote for 🔴</button> | |
<button @click="voteForBlue">Vote for 🔵</button> | |
<h2>Results</h2> | |
<results :red="red" :blue="blue" /> | |
<total-votes :total="red + blue" /> | |
</div> |
This file contains 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> | |
<component :is="componentInstance" /> | |
</div> | |
</template> | |
<script> | |
export default { | |
props: { | |
isCompany: { type: Boolean, default: false }, |
This file contains 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> | |
<component :is="componentName" /> | |
</div> | |
</template> | |
<script> | |
import UserInfo from './components/UserInfo' | |
import CompanyInfo from './components/CompanyInfo' |
This file contains 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> | |
<company-info v-if="isCompany" /> | |
<user-info v-else /> | |
... | |
</div> | |
</template> | |
<script> | |
import UserInfo from './components/UserInfo' |
NewerOlder