Nuxt/examples/vue-class-component/components/Base.vue

48 lines
748 B
Vue
Raw Normal View History

<template>
<div>
<input v-model="msg">
<p>msg: {{ msg }}</p>
<p>env: {{ env }}</p>
<p>computed msg: {{ computedMsg }}</p>
<button @click="greet">
Greet
</button>
<p>
<NuxtLink to="/about">
About page
</NuxtLink>
</p>
</div>
</template>
<script>
import Vue from 'vue'
import Component from 'nuxt-class-component'
2018-08-10 13:45:58 +00:00
export default
@Component({
props: {
env: String
}
})
2018-08-10 13:45:58 +00:00
class Base extends Vue {
// initial data
msg = 123
// lifecycle hook
mounted () {
this.greet()
}
// computed
get computedMsg () {
return 'computed ' + this.msg
}
// method
greet () {
2017-10-31 13:43:55 +00:00
console.log('base greeting: ' + this.msg) // eslint-disable-line no-console
}
}
</script>