mirror of
https://github.com/nuxt/nuxt.git
synced 2025-02-17 06:01:34 +00:00
Fix vue-class-component example
This commit is contained in:
parent
2eecb8c0de
commit
0bea10b857
@ -1,7 +1,7 @@
|
|||||||
module.exports = {
|
module.exports = {
|
||||||
build: {
|
build: {
|
||||||
babel: {
|
babel: {
|
||||||
plugins: ['transform-decorators-legacy']
|
plugins: ['transform-decorators-legacy', 'transform-class-properties']
|
||||||
},
|
},
|
||||||
extend (config) {
|
extend (config) {
|
||||||
config.resolve.alias['nuxt-class-component'] = '~plugins/nuxt-class-component'
|
config.resolve.alias['nuxt-class-component'] = '~plugins/nuxt-class-component'
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "nuxt-class-component",
|
"name": "nuxt-class-component",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
"babel-plugin-transform-class-properties": "^6.24.1",
|
||||||
"babel-plugin-transform-decorators-legacy": "^1.3.4",
|
"babel-plugin-transform-decorators-legacy": "^1.3.4",
|
||||||
"nuxt": "latest",
|
"nuxt": "latest",
|
||||||
"vue-class-component": "^5.0.1"
|
"vue-class-component": "^5.0.1"
|
||||||
|
@ -1,13 +1,11 @@
|
|||||||
<template>
|
<template>
|
||||||
<div>
|
<div>
|
||||||
<input v-model="msg">
|
<input v-model="msg">
|
||||||
<p>prop: {{propMessage}}</p>
|
|
||||||
<p>msg: {{msg}}</p>
|
<p>msg: {{msg}}</p>
|
||||||
<p>env: {{env}}</p>
|
<p>env: {{env}}</p>
|
||||||
<p>helloMsg: {{helloMsg}}</p>
|
|
||||||
<p>computed msg: {{computedMsg}}</p>
|
<p>computed msg: {{computedMsg}}</p>
|
||||||
<button @click="greet">Greet</button>
|
<button @click="greet">Greet</button>
|
||||||
<nuxt-link to="/about">About page</nuxt-link>
|
<p><nuxt-link to="/about">About page</nuxt-link></p>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
@ -15,18 +13,12 @@
|
|||||||
import Vue from 'vue'
|
import Vue from 'vue'
|
||||||
import Component from 'nuxt-class-component'
|
import Component from 'nuxt-class-component'
|
||||||
|
|
||||||
@Component({
|
@Component()
|
||||||
props: {
|
|
||||||
propMessage: String
|
|
||||||
}
|
|
||||||
})
|
|
||||||
export default class App extends Vue {
|
export default class App extends Vue {
|
||||||
// initial data
|
// initial data
|
||||||
msg = 123
|
msg = 123
|
||||||
|
|
||||||
// use prop values for initial data
|
|
||||||
helloMsg = 'Hello, ' + this.propMessage
|
|
||||||
|
|
||||||
asyncData ({ req }) {
|
asyncData ({ req }) {
|
||||||
return { env: req ? 'server' : 'client' }
|
return { env: req ? 'server' : 'client' }
|
||||||
}
|
}
|
||||||
@ -43,7 +35,7 @@ export default class App extends Vue {
|
|||||||
|
|
||||||
// method
|
// method
|
||||||
greet () {
|
greet () {
|
||||||
alert('greeting: ' + this.msg)
|
console.log('greeting: ' + this.msg)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
Loading…
Reference in New Issue
Block a user