[Vuejs]-Vue.js Passing Data via httpVueLoader

5👍

Pass it as you would normally pass values from parent to child; using a prop.

Here is an example.

index.html

<body>
  <div id="app">
    <test :user="user"></test>
  </div>

  <script>
    new Vue({
      el: '#app',
      data: {
        user: "This is a test string"
      },
      components:{
        test: httpVueLoader("/Test.vue")
      }
    })
  </script>
</body>

Test.vue

<template>
  <div>{{user}}
</template>

<script>
module.exports = {
  props:["user"]
}
</script>

This will pass the user defined in the Vue to the Test component and the resulting output will be “This is a test string”.

👤Bert

Leave a comment