0

I'm starting with Vue and I'm trying to understand why this code works

<!-- HTML element -->
<div id="app">{{ message }}</div>
<!-- Script for our app -->
<script>

    const { createApp }     =   Vue

    createApp({
        data() {
            return {
                message     :   'Hello Vue'
            }
        }
    }).mount( '#app' )
</script>

and this one doesn't.

<!-- HTML element -->
<div id="app">{{ message }}</div>
<!-- Script for our app -->
<script>

    const { createApp }     =   Vue

    createApp({
        data() {
            return 
            {
                message     :   'Hello Vue'
            }
        }
    }).mount( '#app' )
</script>

Note that I only did a line jump after the return and now it doesn't work. Is it a syntax related problem?

MiSCapu
  • 13
  • 5
  • 1
    There's an implied semi-colon after the return on its own line. Probably a dup of this https://stackoverflow.com/questions/53154203/why-does-a-return-statement-on-a-new-line-not-return-any-value (which is itself a dup, but IMO has a clearer answer) – danh Aug 16 '22 at 01:35
  • 1
    Does this answer your question? [Why does a return statement on a new line not return any value?](https://stackoverflow.com/questions/53154203/why-does-a-return-statement-on-a-new-line-not-return-any-value) – danh Aug 16 '22 at 01:35

0 Answers0