2014-09-20 2 views
2

첫 번째 Laravel 사이트를 만들려고하지만 내 페이지 중 하나에 JS 파일을 추가하는 방법을 알 수 없습니다.Laravel 페이지에 JS 스크립트 추가

JS 파일 만이 페이지에서 사용하고 다른 곳에서는 사용하지 않기를 바랍니다.

내 페이지에서 JS 파일을로드하려면 어떻게해야합니까?

내 디렉토리 구조는 지금처럼 내 apply.blade.php에서

apply 
    js 
     myjsfile.js 
    apply.blade.php 

@extends('layouts.master') 

@section('content') 
<div class="row"> 
    <div id="applicationForm" class="col-md-9 col-xs-12"> 
    ... 
    </div> 
</div> 

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> 

답변

6

당신의 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 

당신의 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> 
+0

? 모든 JS 파일을 바닥 글에로드하고 싶습니다. – imperium2335

+0

@ imperium2335 내 대답을 편집했습니다. – worldask

관련 문제