【发布时间】:2018-08-29 22:44:11
【问题描述】:
我是 laravel 的新手。我使用 laravel 5.6 。我只想在一页(视图)中使用 Summernote 所见即所得编辑器。 Summernote 需要一个 css 和一个 js 文件。我只想在这个视图中加载这些文件。我该怎么做?
这是我尝试这样做的方法。
master.blade.php 文件。
<html>
@include('header')
<body>
@yield('content')
@include('footer')
</body>
</html>
editor.blade.php文件
@extends('master')
@section('content')
--- Summernote editor goes here---
@endsection
@section('imports')
<link href="http://netdna.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.css" rel="stylesheet">
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.js"></script>
<script src="https://netdna.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.js"></script>
<!-- include summernote css/js-->
<link href="http://cdnjs.cloudflare.com/ajax/libs/summernote/0.8.9/summernote.css" rel="stylesheet">
<script src="https://cdnjs.cloudflare.com/ajax/libs/summernote/0.8.9/summernote.js"></script>
<script>
$(document).ready(function() {
$('.summernote').summernote();
});
</script>
@endsection
header.blade.php
<head>
--- other css and file links ---
@yield('imports')
</head>
你可以看到 editor.blade.php 文件扩展了 master.blade 文件。在主文件中,我包含了包含所有 css 链接的 header.blade 文件。所以我在 header.blade 文件中生成了 Summernote js/css。但是当它加载到浏览器时,header.blade 文件中生成的内容位于<body> 标记的开头(应该在<head> 标记的旁边)。
我可以直接将这些文件添加到 headr.blade.php 文件中。但我想知道是否有办法以这种方式做到这一点。
【问题讨论】:
-
您能否发布实际代码:
---- Summernote css and js file links here --- -
更新帖子@ChrisHappy