Created
February 22, 2019 18:24
-
-
Save takuya-nakayasu/da477f8307889f76731ffe78491c56a0 to your computer and use it in GitHub Desktop.
メッセージコンポーネント
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 v-if="messages.length"> | |
<h2>Messages</h2> | |
<button class="clear" v-on:click="clear()">clear</button> | |
<div v-for="(message, index) in messages" v-bind:key="index"> | |
{{message}} | |
</div> | |
</div> | |
</template> | |
<script> | |
import store from '../../store/store' | |
export default { | |
name: 'Messages', | |
data: function () { | |
return { | |
messages: store.state.messages | |
} | |
}, | |
methods: { | |
clear: function () { | |
this.messages = store.clear() | |
} | |
} | |
}; | |
</script> | |
<style scoped> | |
h2 { | |
color: red; | |
font-family: Arial, Helvetica, sans-serif; | |
font-weight: lighter; | |
} | |
body { | |
margin: 2em; | |
} | |
body, input[text], button { | |
color: crimson; | |
font-family: Cambria, Georgia; | |
} | |
button.clear { | |
font-family: Arial; | |
background-color: #eee; | |
border: none; | |
padding: 5px 10px; | |
border-radius: 4px; | |
cursor: pointer; | |
cursor: hand; | |
} | |
button:hover { | |
background-color: #cfd8dc; | |
} | |
button:disabled { | |
background-color: #eee; | |
color: #aaa; | |
cursor: auto; | |
} | |
button.clear { | |
color: #888; | |
margin-bottom: 12px; | |
} | |
</style> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment