Reputation: 11307
Vue version: 3.0.11
With the following code:
<template>
<button @click="inc">{{ count }}</button>
</template>
<script setup>
import { ref } from 'vue'
export const count = ref(0)
export const inc = () => count.value++
</script>
I got:
ERROR Failed to compile with 1 error
error in ./src/views/HyperScript.vue?vue&type=script&setup=true&lang=js
Syntax Error: TypeError: Cannot read property 'content' of null
@ ./src/views/HyperScript.vue?vue&type=script&setup=true&lang=js 1:0-293 1:0-293 1:294-576 1:294-576
@ ./src/views/HyperScript.vue
@ ./src/router/index.ts
@ ./src/main.ts
@ multi (webpack)-dev-server/client?http://192.168.6.175:8080&sockPath=/sockjs-node (webpack)/hot/dev-server.js ./src/main.ts
Upvotes: 3
Views: 5333
Reputation: 1
You don't need to add export
in your script :
<template>
<button @click="inc">{{ count }}</button>
</template>
<script setup>
import { ref } from 'vue'
const count = ref(0)
const inc = () => count.value++
</script>
Upvotes: 7