Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/facebook/8.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript Vue路由器从Vue路由器链接获取值_Javascript_Php_Laravel_Vue.js_Single Page Application - Fatal编程技术网

Javascript Vue路由器从Vue路由器链接获取值

Javascript Vue路由器从Vue路由器链接获取值,javascript,php,laravel,vue.js,single-page-application,Javascript,Php,Laravel,Vue.js,Single Page Application,我的桌子上有一张单子。它有一个编辑按钮,如果我单击编辑按钮,它将转到另一个名为editTeacher的组件。我的问题是如何从表中获取数据并将其传输到我的editTeacher组件。我使用axios从route获取数据。在拉威尔,情况是这样的 我如何在vue中实现它 这是我的代码片段 <table id="myTable" class="table table-hover"> <tbody> <tr> <th>ID</th&

我的桌子上有一张单子。它有一个编辑按钮,如果我单击编辑按钮,它将转到另一个名为
editTeacher
的组件。我的问题是如何从表中获取数据并将其传输到我的
editTeacher
组件。我使用axios从route获取数据。在拉威尔,情况是这样的

我如何在vue中实现它

这是我的代码片段

<table id="myTable" class="table table-hover">
  <tbody>
   <tr>
    <th>ID</th>
    <th>Image</th>
    <th>First Name</th>
    <th>Last Name</th>
    <th>Gender</th>
    <th>Birthday</th>
    <th>Age</th>
    <th>Type</th>
    <th>Department</th>
    <th>Status</th>
    <th>Actions</th>
   </tr>
   <tr v-for="teacher in teachers" :key="teacher.id">
    <td>{{teacher.id}}</td>
    <td><img style=" border-radius: 50%;" :src="'img/'+teacher.image"  height="42" width="42"/></td>
    <td>{{teacher.firstname}}</td>
    <td>{{teacher.lastname}}</td>
    <td>{{teacher.gender}}</td>
    <td>{{teacher.birthday}}</td>
    <td>{{teacher.age}}</td>
    <td>{{teacher.type}}</td>
    <td>{{teacher.department_name}}</td>
    <td v-if="teacher.status == 1"><span  class="label label-success">Active</span></td>
    <td v-else><span  class="label label-danger">Inactive</span></td>
    <td><router-link to="/viewTeacher"> <i class="fa fa-edit"></i></router-link></td>
   </tr>
  </tbody>
</table>
app.js路线

{ path: '/viewTeacher', component: require('./components/editTeacher.vue').default },

请遵循以下Vue js编辑方法的代码。 根据您的git回购协议

app.js路线

{ path: '/viewTeacher/:id', component: require('./components/editTeacher.vue').default, name: viewTeacher},
<router-link :to="{name: 'viewTeacher', params: {id: teacher.id}}" class="btn btn-xs btn-default">Edit</router-link>
教师.vue中的编辑按钮

{ path: '/viewTeacher/:id', component: require('./components/editTeacher.vue').default, name: viewTeacher},
<router-link :to="{name: 'viewTeacher', params: {id: teacher.id}}" class="btn btn-xs btn-default">Edit</router-link>
控制器

public function show($id)
{
    return Teacher::findOrFail($id);
}

谢谢,先生。让我试试这个。稍后让我提问数据是空白的,先生。但是我有身份证。我怎么能解决这个问题?我的回购协议在这里。如果您有时间,请帮助我,先生@Vince我已经更新了答案,请检查。我给了你一个基本的想法。@Vince我没有足够的时间来测试你的回购协议。但是什么是错误发生?听起来你需要考虑使用全局状态管理,使用VUEX会解决你的问题。我是VUE的新手,我只想用简单的方法来解决这个问题。对不起,先生
public function show($id)
{
    return Teacher::findOrFail($id);
}