laravel - vue中如何使用axios获取id选择的数据
问题描述
app.js:50345 [Vue 警告]:无效的道具:道具“数据”的类型检查失败。预期对象,得到值为“”的字符串。
这就是我路由数据和分页的方式
Route::get('project',function(){
return App\project::latest()->paginate(5);});
这就是我展示的方式
<td>{{projectownerdata && projectownerdata.project_id}}</td>
这是我在 vue 中的脚本
<script>
export default {
data(){
return{
projectownerdata :{
},
form: new Form({
project_id:'',
project_name:'',
project_code:'',
tct_number:'',
project_status:'New',
address:''
})
}
},
methods:{
//For Pagination
getResults(page = 1) {
axios.get('api/project?page=' + page)
.then(response => {
this.projectownerdata = response.data
})
},
loadProjects(){
axios.get('api/project/'+ this.$route.params.id)
.then(response => {
this.projectownerdata = response.data
});
}
},
created(){
this.loadProjects();
},
}
</script>
解决方案
推荐阅读
- ruby-on-rails - has_many :通过不加载记录
- angular - 在 ng 中使用功能模块的推荐做法是什么?
- javascript - 决定应用程序的 Javascript 发布/订阅模式
- python - 没有名为 flask_bcrypt 的模块
- spring-boot - Spring Boot - Hikari 数据库配置
- java - AWS 上的 Apache 目录工作室
- php - PHP如何使用数据库数据制作下拉菜单
- php - 有没有办法可以通过 CSS 类标题编辑 CSS 变量?
- java - Google Camera API 应用程序在重新进入时崩溃
- xaml - XAML 按钮单击事件中的签名不正确