Skip to content

Instantly share code, notes, and snippets.

@komatatsu
Last active February 17, 2019 06:40
Show Gist options
  • Save komatatsu/4d59d1c5d9a201bf1312ca5289a71296 to your computer and use it in GitHub Desktop.
Save komatatsu/4d59d1c5d9a201bf1312ca5289a71296 to your computer and use it in GitHub Desktop.
vue.jsใ‚’ไฝฟใฃใฆ๐Ÿ’ฉใ‚’ๅข—ใ‚„ใ—ใŸใ‚Šๆตใ—ใŸใ‚Šใ™ใ‚‹

vue.jsใ‚’ใ‚„ใฃใฆใฟใŸใ‹ใฃใŸใฎใงใ€ใฟใ‚“ใชใฎๅคงๅฅฝใใช๐Ÿ’ฉใ‚’ๅข—ใ‚„ใ—ใŸใ‚Šๆตใ—ใŸใ‚Šใ—ใŸ

  1. ๐Ÿ’ฉใ‚’ๅข—ใ‚„ใ™
  2. ๐Ÿ’ฉใ‚’ใ‚ณใƒณใƒใƒผใƒใƒณใƒˆๅŒ–ใ™ใ‚‹
  3. ๐Ÿ’ฉใ‚’ๆตใ™

ใจใ„ใ†ใ‚นใƒ†ใƒƒใƒ—ใงใ‚„ใฃใฆใ„ใใพใ™
่ฆ‹ใŸ็›ฎใจๆŒฏใ‚‹่ˆžใ„ใ‚’ใ‚ณใƒณใƒใƒผใƒใƒณใƒˆใซใพใจใ‚ใ‚‰ใ‚Œใ‚‹ใฎใฏไธญใ€…่‰ฏใ•ใใ†

๐Ÿ’ฉใฏๆตใ›ใ‚‹ๆง˜ใซใชใฃใŸใ‘ใฉใ“ใ‚ŒใงใชใซใŒใงใใ‚‹ใฎใ‹ใพใ ๆƒณๅƒใงใใชใ„

ใ‚ชใƒฌใฏใ‚ˆใ†ใ‚„ใใฎใผใ‚Šใฏใ˜ใ‚ใŸใฐใ‹ใ‚Šใ ใ‹ใ‚‰ใช
ใ“ใฎใฏใฆใ—ใชใ้ ใ„vueๅ‚ใ‚’ใ‚ˆ...

<!doctype html>
<html>
<head>
<script src="https://cdn.jsdelivr.net/npm/vue"></script>
<title>๐Ÿ’ฉ</title>
</head>
<body>
<div id=app>
<p>{{message}}</p>
<button v-on:click="add">ๅข—ใˆใ‚‹</button>
</div>
</body>
<script>
new Vue({
el: '#app',
data: {
message: "๐Ÿ’ฉ"
},
// v-onใ‚’่จญๅฎšใ—ใŸ่ฆ็ด ใฏ el ใงๆŒ‡ๅฎšใ—ใŸ่ฆ็ด ใฎ้…ไธ‹ใซใชใ„ใจๅ‡ฆ็†ใŒๅ‘ผใฐใ‚Œใชใ„
methods: {
add: function() {
this.message = this.message + " ๐Ÿ’ฉ"
}
}
})
</script>
</html>
<!doctype html>
<html>
<head>
<script src="https://cdn.jsdelivr.net/npm/vue"></script>
<title>๐Ÿ’ฉ</title>
</head>
<body>
<div id=app>
<unko></unko>
</div>
</body>
<script>
Vue.component('unko', {
template: `
<div>
<p>{{message}}<p>
<button v-on:click="add">ๅข—ใˆใ‚‹</button>
</div>
`,
data: function() {
return {
message: "๐Ÿ’ฉ"
}
},
methods: {
add: function() {
this.message = this.message + " ๐Ÿ’ฉ"
}
}
})
new Vue({ el: '#app' })
</script>
</html>
<!doctype html>
<html>
<head>
<script src="https://cdn.jsdelivr.net/npm/vue"></script>
<title>๐Ÿ’ฉ</title>
</head>
<body>
<div id=app>
<unko></unko>
</div>
</body>
<script>
Vue.component('unko', {
template: `
<div>
<template v-if="isFlush">
<marquee>{{message}}</marquee>
</template>
<template v-else>
<p>{{message}}</p>
</template>
<button v-on:click="add">ๅข—ใˆใ‚‹</button>
<button v-on:click="flush">ๆตใ™</button>
</div>
`,
data: function() {
return {
message: "๐Ÿ’ฉ",
isFlush: false
}
},
methods: {
add: function() {
this.message = this.message + " ๐Ÿ’ฉ"
},
flush: function() {
this.isFlush = true
}
}
})
new Vue({ el: '#app' })
</script>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment