【发布时间】:2020-10-21 04:10:50
【问题描述】:
我为“writer”创建了其他 Vue.js 管理页面,我可以在其中从 mysql DB 帖子中显示数据帖子。在管理页面“管理员”数据响应并且一切正常。
我想要数据的帖子页面。
<template>
<div>
<h1>POOST</h1>
<section class="posts-page">
<div
v-for="post in posts"
:key="post.id"
/>
{{ post }}
</section>
</div>
</template>
<script>
export default {
data() {
return {
posts: []
}
},
created() {
axios.get('/api/posts/').then(console.table())
}
}
</script>
<style>
API PostController.php
public function index()
{
return Post::with('user')->latest('id')->get();
}
感谢一切。
【问题讨论】:
-
在大括号前放一个
@符号。否则它将充当 echo@{{post}} -
@STA 控制台错误是
Vue warn]: Property or method "post" is not defined on the instance but referenced during render. Make sure that this property is reactive, either in the data option, or for class-based components, by initializing the property. See: https://vuejs.org/v2/guide/reactivity.html#Declaring-Reactive-Properties. -
和 ``` Uncaught (in promise) 错误:请求失败,状态码 401
标签: javascript laravel vue.js axios