vuejs/vue2-ssr-docs

Accessing the context data

chiqui3d opened this issue · 0 comments

Hello,
At this point https://ssr.vuejs.org/guide/#using-a-page-template, where do you pass the context object, how does it get that message data in the component?

   const renderer = createRenderer({
  template: require('fs').readFileSync('./index.html', 'utf-8'),
});
    const context = {
      message: 'Esto es otro',
    };
    app.message = 'Hello';
    renderer.renderToString(app, context, (err, html) => {
      return res.status(200).send(html);

    });

After searching for a few hours, I was able to get the data through the parent, is it the right way, or is there another way?

<template>
    <div class="greeting">Esto es un mensaje 1233 - {{message}} </div>
</template>
<style lang="css">
    .greeting {
        font-size: 20px;
        color:red !important;
    }
</style>
<script>
  export default {
    created() {
      this.message = this.$parent.message; //Grab this data from the parent
    }
  };
</script>