I got te top late to be loaded with router, and can load data with AJAX request
but I can’t push them back inside the template
and i don’t know I to pass a variable to the template I’m going to load
I need to specify the ID to my endpoint to load the data i need
this is what I got to work so far
<!-- component template -->
<template>
<div class="page">
<div class="navbar">
<div class="navbar-inner">
<div class="title">{{title}}</div>
</div>
</div>
<div class="page-content">
<div class="list simple-list">
<ul>
{{#each names}}
<li>{{this}}</li>
{{/each}}
</ul>
</div>
<div class="block block-strong">
<a href="#" class="link back">
<i class="icon icon-back"></i>
<span class="ios-only">Back</span>
</a>
</div>
</div>
</div>
</template>
<script>
/* https://framework7.io/docs/request.html */
// script must return component object
return {
data: function () {
return {
title: 'Component Page',
names: [],
}
},
on: {
pageInit() {
var self = this;
var app = self.$app;
app.request.get('../json/test-d-01.json?id=xxx', function (data) {
var d = JSON.parse(data);
console.log(d);
console.log(d.ptitle);
return {
title: d.ptitle,
names: d.pnames,
}
/*self.$setState({
names: jsondata.names,
});*/
});
},
}
}
</script>