<!-- fichier index.html -->

<!DOCTYPE html>
<html lang="fr">
  <head><title>index.html</title></head>
  <body>
    <div id="app">
        <span>{{ messageFinal() }}</span>
    </div>
    <!-- chargement de la librairie Vue.js -->
    <script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
    <script>
      const app = new Vue({
        el: "#app",
        data: {
          message: "Bonjour tout le monde",
          taille: 10
        },
        methods: {
          messageFinal: function() {
            if (this.message.length > this.taille) {
              return this.message.slice(0, this.taille - 3).concat('', '...');
            }

            return this.message; 
          }  
        },
      });
    </script>
  </body>
</html>
