Answer the question
In order to leave comments, you need to log in
How to access data in an array?
Hello.
php file
<?
$aMenuLinks = Array(
Array(
"Каталог курсов",
"index.php",
Array(),
Array(),
""
),
Array(
"Мои курсы",
"mycourses.php",
Array(),
Array(),
""
),
);
echo json_encode($aMenuLinks);
?>
<div id="app2">
<div v-for="inform in info">
{{ inform }}
</div>
</div>
var app2 = new Vue ({
el: '#app2',
data() {
return {
info: null
};
},
mounted() {
axios
.get('test.php')
.then(response => (this.info = response.data));
}
})
[ "Каталог курсов", "index.php", [], [], "" ]
[ "Мои курсы", "mycourses.php", [], [], "" ]
Answer the question
In order to leave comments, you need to log in
If you change in PHP file
<?
$aMenuLinks = Array(
Array(
"page"=>"Каталог курсов",
"link"=>"index.php",
"foo" => Array(),
"bar" => Array(),
"dollar"=> ""
),
Array(
"page"=>"Мои курсы",
"link"=>"mycourses.php",
"foo"=> Array(),
"bar" =>Array(),
"dollar" =>""
),
);
echo json_encode($aMenuLinks);
?>
<div id="app2">
<div v-for="inform in info">
<a v-bind:href="inform.link">{{inform.page}}</a>
</div>
var app2 = new Vue ({
el: '#app2',
data() {
return {
info: null
};
},
mounted() {
axios
.get('test.php')
.then(response => (this.info = response.data));
}
})
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question