【发布时间】:2016-03-03 11:57:26
【问题描述】:
我对 laravel 很陌生。路线如下:
Route::get('/imagess','cont@imagess');
Route::get('/imagess/details/{id}','cont@image_details');
控制器文件中的功能是:
public function imagess() {
return view('imagess');
}
public function image_details($id) {
return view('image_details');
}
查看文件为imagess.blade.php
@extends('inside.main')
@section('content')
<img src="{{asset('images/play.png')}}" height="100px" width="100px"><a href="{{url('imagess/details/1')}}">View image 1</a><br>
<img src="{{asset('images/eat.png')}}" height="100px" width="100px"><a href="{{url('imagess/details/2')}}">View image 2</a><br>
<img src="{{asset('images/sleep.png')}} height="10px" width="10px""><a href="{{url('imagess/details/3')}}">View image 3</a><br>
tihsajf
<img src="{{asset('images/read.png')}}" height="100px" width="100px"><a href="{{url('imagess/details/4')}}">View image 4</a><br>
@endsection
我的imagess_details.blade.php 应该是什么来显示这些图像的基本细节?我不想使用数据库显示确切的详细信息。只是显示任何东西。例如。如果我点击 image1 则显示“你好”,如果我点击 image2 则显示“begineer”,如果我点击 image3 则显示“here”等等..
如果我按如下方式制作images_details。无论我单击 image1、image2 还是任何其他图像,它都会显示“你好”。
@extends('inside.main')
@section('content')
<h2>hello</h2>
@endsection
【问题讨论】:
-
为什么“imagess”有两个“S”,为什么你的控制器和动作名称不使用StudlyCased名称?
-
images_details将始终显示“Hello”,因为它是静态的?你需要从你的控制器传递一些东西到视图。 -
如果我的回答有帮助,请点赞并选为最佳答案。