Home  >  Q&A  >  body text

Problems encountered when using export default in Vue

Code Error

I tried running the above code, but it didn't work and I couldn't see anything in the browser. Is there any other way to write the code in <scripts setup> </script>? What I learned is that the function is placed in export default { name: 'App', //code }中 Because when I type anything else, like console.log('It runs'), I get an error and can't even see 'hello world'? Please help ;-;

P粉769413355P粉769413355424 days ago582

reply all(1)I'll reply

  • P粉276876663

    P粉2768766632023-09-13 09:38:30

    your code error

    // App.vue
    <script setup lang="ts">
    import { onMounted, reactive, toRefs } from 'vue'
    
    const state = reactive({
        showNavbar: 'xxxx'
    })
    const { showNavbar } = toRefs(state)
    
    onMounted(async() => {
       console.log('hello world')
    })
    
    </script>
    
    <template>
    
        <main>
             <RouterView />
        </main>
       
    </template>
    
    <style lang="scss" scoped>
    
    </style>

    reply
    0
  • Cancelreply