imp*_*335 2 laravel blade laravel-4
我正在尝试创建我的第一个Laravel站点,但我无法弄清楚如何将JS文件添加到我的一个页面.
我只希望在这个页面上使用JS文件,而不是在其他地方使用.
如何让我的页面加载JS文件?
我的目录结构是这样的:
apply
js
myjsfile.js
apply.blade.php
Run Code Online (Sandbox Code Playgroud)
在我的apply.blade.php中
@extends('layouts.master')
@section('content')
<div class="row">
<div id="applicationForm" class="col-md-9 col-xs-12">
...
</div>
</div>
Run Code Online (Sandbox Code Playgroud)
layouts.master文件
<!DOCTYPE html>
<html>
<head>
@include('includes.head')
</head>
<body>
<div class="container">
<div id="header">
@include('includes.header')
</div>
@yield('content')
<div id="footer">
@include('includes.footer')
</div>
</div>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
wor*_*ask 10
您的 apply.blade.php
@extends('layouts.master')
@section('content')
<div class="row">
<div id="applicationForm" class="col-md-9 col-xs-12">
...
</div>
</div>
@stop
@section('myjsfile')
<script src="js/myjsfile.js"><script>
@stop
Run Code Online (Sandbox Code Playgroud)
您的 layouts.master
<!DOCTYPE html>
<html>
<head>
@include('includes.head')
</head>
<body>
<div class="container">
<div id="header">
@include('includes.header')
</div>
@yield('content')
<div id="footer">
@include('includes.footer')
</div>
</div>
@yield('myjsfile')
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
9337 次 |
| 最近记录: |