Javascript/nuxtjs/helloworld
提供: 初心者エンジニアの簡易メモ
pages/index.vue
<template>
<div id="app">
<h1>{{ msg }}</h1>
</div>
</template>
<script>
export default {
name: 'app',
data() {
return {
msg: 'Welcome to App'
}
},
mounted() {
// インスタンスがマウントされた直後に実行
}
}
</script>
<style>
#app {
font-family: 'Avenir', Helvetica, Arial, sans-serif;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
text-align: center;
color: #2c3e50;
margin-top: 60px;
}
h1, h2 {
font-weight: normal;
}
ul {
list-style-type: none;
padding: 0;
}
li {
display: inline-block;
margin: 0 10px;
}
実行
$ yarn dev
ライフサイクル
以下順番で呼ばれる
- beforeCreate,
- created
- beforeMount
- mouted
- beforeUpdate
- updated
- beforeDestroy
- destroyed
computed,methods,watch周り
- computed:dataの値を更新する処理
- methods:再描画時に実行されるメソッド
- watch:値が更新されたときに実行されるメソッド
参考
Javascript/vue/node/helloworld [ショートカット]
