0

I started learning Vue for real now and 'm following videos from Jeffrey Way Vue 2....and in this video https://laracasts.com/series/learn-vue-2-step-by-step/episodes/9 he has 2 messages in html and on my side it doesn't work.... this is my code...just copy paste it in .html document and it works...so if someone can explain it to me why does my second message doesn't display??

<!-- begin snippet -->

<!DOCTYPE html>
<html>
<head>
    <title>Index</title>
    <!-- <link rel="stylesheet" type="text/css" href="/var/www/html/vanilla/Vue/bulma.min.css"> -->
    <link rel="stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/bulma/0.6.0/css/bulma.min.css">
</head>
<body>

<div id="root" class="container">

    <message title="Hello World" body="Lorem ipsum dolor sit amet"><message>
    <message title="Hello Latin" body="Repetitio est mater studiorum"><message>

</div>

<!-- <script src="/var/www/html/vanilla/Vue/vue.js"></script> -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.5.2/vue.min.js"></script>
<script>
    Vue.component('message', {

    props: ['title', 'body'],

    data() {
        return {
            isVisible: true
        }
    },

    template: `
        <article class="message" v-show="isVisible">
          <div class="message-header">
              {{ title }}
              <button class="button" @click="hideModal">X</button>
          </div>
          <div class="message-body">
            {{ body }}
          </div>
        </article>
        `,

    methods: {
        hideModal() {
            this.isVisible = false;
        }
    }
});

new Vue({
    el: '#root'
});

</script>
</body>
</html>

<!-- end snippet -->

this one doesn't get shown

<message title="Hello Latin" body="Repetitio est mater studiorum"><message>

2 Answers 2

1
<message title="Hello World" body="Lorem ipsum dolor sit amet"><message>

Should be

<message title="Hello W`enter code here`orld" body="Lorem ipsum dolor sit amet"></message>

You are missing closing tags </message>

Sign up to request clarification or add additional context in comments.

2 Comments

Did you try the code? The message tags are properly closed!
Yes. Did you? Here is the working example plnkr.co/edit/XypvmN6MGMKWhM6KJhq4?p=preview
0

Try this

<html>
    <head>
        <title>Index</title>
        <!-- <link rel="stylesheet" type="text/css" href="/var/www/html/vanilla/Vue/bulma.min.css"> -->
        <link rel="stylesheet" type="text/css" >
    </head>
    <body>
    
    <div id="root" class="container">
        <message :title="title" :body="body"></message>
    
    </div>
    
    <script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.5.2/vue.min.js"></script>
    <script>
        Vue.component('message', {
    
        props: ['title', 'body'],
    
        data() {
            return {
                isVisible: true
            }
        },
    
        template:'#bodyt',
            
    
        methods: {
            hideModal() {
                this.isVisible = false;
            }
        }
    });
    
    new Vue({
        el: '#root',
        data: {
        title: 'Hello Latin',
        body:'Repetitio est mater studiorum',
        },
    });
    </script>
    
    <template id="bodyt">
    
    <article class="message" v-show="isVisible">
              <div class="message-header">
                  {{ title }}
                  <button class="button" @click="hideModal">X</button>
              </div>
              <div class="message-body">
                {{ body }}
              </div>
            </article>
    </template>
            
    </body>
    </html>

1 Comment

Bsalex has the right answer...i forgot to close the message tags...i did wrote the ending tags but forgot the / slash

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.