我实际上正在努力将数据传递到 GET 请求页面,我试图将数据从数据库传递到 Dashboard.vue 组件(使用 Laravel 8 + Inertia.js 堆栈)
但是什么也没发生,为什么?
控制器组件:
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>