Javascript 拉威尔8号+;惯性不是渲染变量
实际上,我正在努力将数据传递到GET请求页面,在该页面中,我试图将数据从数据库传递到Dashboard.vue组件(使用Laravel 8+Inerty.js堆栈) 但什么都没发生,为什么 控制器组件:Javascript 拉威尔8号+;惯性不是渲染变量,javascript,php,laravel,vue.js,inertiajs,Javascript,Php,Laravel,Vue.js,Inertiajs,实际上,我正在努力将数据传递到GET请求页面,在该页面中,我试图将数据从数据库传递到Dashboard.vue组件(使用Laravel 8+Inerty.js堆栈) 但什么都没发生,为什么 控制器组件: public function index(Request $request) { return Inertia::render('Dashboard', [ 'percentages' => $percentages = DB::table('pr
public function index(Request $request)
{
return Inertia::render('Dashboard', [
'percentages' => $percentages = DB::table('profits')->where('user_id', $request->user()->id)->sum('percentage'),
'profits' => $profits = DB::table('profits')->where('user_id', $request->user()->id)->sum('total_profit'),
]);
}
前端:
<div class="container">
<div class="row">
<div class="col-sm-5 text-center fund-profits">
{{profits}}
</div>
<div class="col-sm-2 text-center nomad-separator">
|
</div>
<div class="col-sm-5 text-center fund-profits">
{{percentages}}
</div>
</div>
</div>
<script>
import JetApplicationLogo from './../Jetstream/ApplicationLogo'
export default {
props: ['percentages', 'profits'],
components: {
JetApplicationLogo,
},
}
</script>
{{利润}
|
{{百分比}
从“/../Jetstream/ApplicationLogo”导入JetApplicationLogo
导出默认值{
道具:[‘百分比’、‘利润’],
组成部分:{
JetApplicationLogo,
},
}
我昨天也遇到了类似的问题。
我再次通过惯性在routes/web.php
中渲染,我相信有一个覆盖。试着在你的路线上不要使用惯性,这对我很有用
路由::get('/your_Route',[YourController::class',index'])
我昨天也有类似的问题。 我再次通过惯性在
routes/web.php
中渲染,我相信有一个覆盖。试着在你的路线上不要使用惯性,这对我很有用
路由::get('/your_Route',[YourController::class',index'])
这里是Inerty.js的创建者 我认为您在这里所做的没有任何问题,假设您显示的Vue组件实际上是
Dashboard.Vue
page组件
我建议使用检查接收到的道具,以确保它们正确地来自服务器。这里是Inerty.js的创建者 我认为您在这里所做的没有任何问题,假设您显示的Vue组件实际上是
Dashboard.Vue
page组件
我建议使用检查接收的道具,以确保它们正确来自服务器。在我的情况下,惯性路由中间件未应用,因此我应用了惯性路由中间件,它再次开始工作
在我的例子中,惯性路由中间件没有应用,所以我应用了惯性路由中间件,它又开始工作了