I’m facing a problem in vue route. The problem is vue route is not render data property 'people' of vue js instance. Please guide me what is the problem here. Here is my code.
Console Error:
Property or method "people" is not defined on the instance but referenced during render. Make sure to declare reactive data properties in the data option.
and also my running code available here:JsFiddle Code
<body>
<div id="vue-app">
<router-link to='/list'>Show People List</router-link>
<!-- router outlet -->
<router-view></router-view>
</div>
<script src="https://unpkg.com/vue/dist/vue.js"></script>
<script src="https://unpkg.com/vue-router/dist/vue-router.js"></script>
<script type="text/x-template" id="list_template">
<div>
<div v-for="person in people ">
<p v-text="person.name"></p>
</div>
<p>create display here </p>
</div>
</script>
<script type="text/javascript">
const list = {
template: '#list_template'
};
const routes = [
{path: '/list', component: list,},
];
const router = new VueRouter({
routes: routes,
});
const app = new Vue({
router: router,
data(){
return {
people: [
{name: "Ali"},
{name: "Kamran"},
{name: "Qaiser"},
],
}
}
}).$mount('#vue-app')
</script>