[Vuejs]-Cannot render Vue-js in template

0👍

You may of course use Vue inside of templates.

The error you are receiving is because you incorrectly setting the data property. You have set list and test to the parent component, while you are trying to access them in your child list component. This produces an error while Vue tries to render the component, and thus the component is not rendered at all.

To fix just change your list component to the following:

const list = {
  data () {
    return {
      list: [],
      test: "Now you should see me :)"
    }
  },
  template: '<table><tr v-for="item in list"><td><router-link v-on:click.native="doSomething" v-bind:to="\'/item/\' + item.id">{{ item.title }}</router-link></td></tr></table>'
}

You will also need to move your methods to the component where you are using them.

👤tam5

Leave a comment