|--assets
| |--css
| | |--select2.min.css
| |--js
| | |--components
| | | |--Example.vue
| | |--app.js
| | |--bootstrap.js
| | |--select2.min.js
| |--sass
| | |--app.scss
| | |--
gulpfile.js 文件
const elixir = require('laravel-elixir');
require('laravel-elixir-vue-2');
/*
|--------------------------------------------------------------------------
| Elixir Asset Management
|--------------------------------------------------------------------------
|
| Elixir provides a clean, fluent API for defining some basic Gulp tasks
| for your Laravel application. By default, we are compiling the Sass
| file for your application as well as publishing vendor resources.
|
*/
elixir((mix) => {
mix.sass('app.scss')
.webpack('app.js');
});
app.blade.php 文件
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- CSRF Token -->
<meta name="csrf-token" content="{ csrf_token() }">
<title>{ config('app.name', 'Laravel') }</title>
<!-- Styles -->
<link href="/css/app.css" rel="stylesheet">
<!-- Scripts -->
<script>
window.Laravel = <?php echo json_encode([
'csrfToken' => csrf_token(),
]); ?>
</script>
</head>
<body>
<div id="app">
<nav class="navbar navbar-default navbar-static-top">
<div class="container">
<div class="navbar-header">
<!-- Collapsed Hamburger -->
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#app-navbar-collapse">
<span class="sr-only">Toggle Navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<!-- Branding Image -->
<a class="navbar-brand" href="{ url('/') }">
{ config('app.name', 'Laravel') }
</a>
</div>
<div class="collapse navbar-collapse" id="app-navbar-collapse">
<!-- Left Side Of Navbar -->
<ul class="nav navbar-nav">
</ul>
<!-- Right Side Of Navbar -->
<ul class="nav navbar-nav navbar-right">
<!-- Authentication Links -->
@if (Auth::guest())
<li><a href="{ url('/login') }">Login</a></li>
<li><a href="{ url('/register') }">Register</a></li>
@else
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">
{ Auth::user()->name } <span class="caret"></span>
</a>
<ul class="dropdown-menu" role="menu">
<li>
<a href="{ url('/logout') }"
onclick="event.preventDefault();
document.getElementById('logout-form').submit();">
Logout
</a>
<form id="logout-form" action="{ url('/logout') }" method="POST" style="display: none;">
{ csrf_field() }
</form>
</li>
</ul>
</li>
@endif
</ul>
</div>
</div>
</nav>
@yield('content')
</div>
<!-- Scripts -->
<script src="/js/app.js"></script>
</body>
</html>
questions/make,blade.php 文件
@extends('layouts.app')
@section('content')
@include('vendor.ueditor.assets')
<div class="container">
<div class="row">
<div class="col-md-8 col-md-offset-2">
<div class="panel panel-default">
<div class="panel-heading">发布问题</div>
<div class="panel-body">
<form action="/questions" method="post">
{!! csrf_field() !!}
<div class="form-group{ $errors->has('title') ? 'has-error' : '' }">
<label for="title">标 题</label>
<input type="text" value="{ old('title') }" name="title" class="form-control" placeholder="标题" id="title">
@if ($errors->has('title'))
<span class="help-block">
<strong>{ $errors->first('title') }</strong>
</span>
@endif
</div>
<div class="form-group{ $errors->has('body') ? 'has-error' : '' }">
<label for="body">描述</label>
<!-- 编辑器容器 -->
<!-- 非转义可能引起攻击,需要过滤 -->
<script id="container" name="body" type="text/plain" style="height:200px;">
{!! old('body') !!}
</script>
@if ($errors->has('body'))
<span class="help-block">
<strong>{ $errors->first('body') }</strong>
</span>
@endif
</div>
<button class="btn btn-success pull-right" type="submit">发布问题</button>
</form>
</div>
</div>
</div>
</div>
</div>
<!-- 实例化编辑器 -->
<script type="text/javascript">
var ue = UE.getEditor('container', {
toolbars: [
['bold', 'italic', 'underline', 'strikethrough', 'blockquote', 'insertunorderedlist', 'insertorderedlist', 'justifyleft','justifycenter', 'justifyright', 'link', 'insertimage', 'fullscreen']
],
elementPathEnabled: false,
enableContextMenu: false,
autoClearEmptyNode:true,
wordCount:false,
imagePopup:false,
autotypeset:{ indent: true,imageBlockLine: 'center' }
});
ue.ready(function() {
ue.execCommand('serverparam', '_token', '{ csrf_token() }'); // 设置 CSRF token.
});
</script>
@endsection