.vue 单文件代码 例如
<template>
<div class="content nsr-card-bg">
<div class="nsr-card" v-for="res in result">
<img v-bind:src="res.img" alt="">
<p>{{res.content}}</p>
<div class="nsr-card-user-info">
<p>
<img v-bind:src="res.avatar" alt="">
<span>from</span>{{res.nickname}}
</p>
<p class="fa fa-map-marker">{{res.address}}</p>
</div>
</div>
</div>
</template>
<script>
var data = [];
fetch('/server.php')
.then(function(response) {
return response.json()
}).then(function(json) {
data = json;
console.log(json);
}).catch(function(ex) {
console.log(ex);
});
module.exports={
data:function () {
return {
result : data
}
}
}
</script>