$ npx create-nuxt-app nuxt-app
$ cd nuxt-app
Modify /pages/index.vue.
<template>
<section class="container">
{{ name }}
</section>
</template>
<script>
class Sample {
static NAME = 'Alice'
}
export default {
data() {
return {
name: Sample.NAME
}
}
}
</script>
Start Nuxt.js app
$ npm run dev
Start the application and create the instance having data: {name: 'Alice'}.
Throw an Error: SyntaxError Unexpected token export
FYI銆乀his happens when mode is set to universal. Mode spa will work just fine.
Having the same problem. App crashes whenever I add properties to my classes.
A simple example here https://codesandbox.io/s/jv34jj5wl5
Switching mode to spa is not option for everyone.
@Arnique The PR to fix this issue was merged but the new version of Nuxt is not out yet. You need to wait until the next release.
@Arnique The PR to fix this issue was merged but the new version of Nuxt is not out yet. You need to wait until the next release.
Thanks for working on this.
For now I got it to work by installing babel-plugin-transform-class-properties and adding it in the config i.e
build: {
babel: {
plugins: ['babel-plugin-transform-class-properties']
}
}