我现在很困惑,我正在从Laracast学习Laravel,根据讲师的说法,在验证失败后,表单不会重置用户输入的值.但是在测试验证时,当我提交表单重置每一件事.
另一个问题是当我尝试访问它时未定义的变量 $errors.
我的控制器
<?php
namespace App\Http\Controllers;
use App\Articles;
use App\Http\Requests\CreateArticle;
use Carbon\Carbon;
use App\Http\Requests;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
class ArticlesController extends Controller
{
public function create()
{
return view('articles.create');
}
public function store(Request $request)
{
$this->validate($request, [
'title' => 'required',
'body' => 'required'
]);
Articles::create($request->all());
return redirect('articles');
}
}
Run Code Online (Sandbox Code Playgroud)
我的看法
@extends('app')
@section('content')
<h1>Create a new Articles</h1>
<hr/>
{!! Form::open(['url' => 'articles']) !!}
<div class="form-group">
{!! Form::label('title', 'Title: ') !!}
{!! Form::text('title', null, ['class' => 'form-control']) !!}
</div> …Run Code Online (Sandbox Code Playgroud) 我只找到有关如何保存会话变量的信息,其效果如下: $request->session()->put('key', 'value');
但是如何在刀片视图中访问会话?
我正在开发一个初始页面,用户可以使用公式来添加页面链接.他们可以添加名称,网址,说明和上传图片.
我想自动上传图像的过程,应该自动捕获图像.我的脚本应该截取用户在网址中输入的网站的屏幕截图.我知道我可以使用html2canvas截取html元素的截图.
我的第一种方法是将外部网站加载到iframe,但这不起作用,因为有些页面限制了这一点,例如甚至w3schools.com上的iframe教程都不起作用我得到了Refused to display 'https://www.w3schools.com/' in a frame because it set 'X-Frame-Options' to 'sameorigin'.
HTML
<div id="capture" style="padding: 10px; color: black;">
<iframe src="https://www.w3schools.com"></iframe>
</div>
Run Code Online (Sandbox Code Playgroud)
我的下一个方法是打电话给我的网络服务器,它加载目标网站并将html返回给客户端.这样可行,但目标站点未正确呈现,例如图像未加载.(见下面的截图)
HTML
<div id="capture" style="padding: 10px; color: black;"></div>
Run Code Online (Sandbox Code Playgroud)
JS
var testURL = "http://www.google.de";
$.ajax({
url: "http://server/ajax.php",
method: "POST",
data: { url: testURL},
success: function(response) {
$("#capture").html(response);
console.log(response);
html2canvas(document.querySelector("#capture")).then(
canvas => {
document.body.appendChild(canvas);
}
);
}
});
Run Code Online (Sandbox Code Playgroud)
PHP
if …Run Code Online (Sandbox Code Playgroud) 可以设置蓝色矩形的样式吗?我需要将颜色更改为橙色。
有一些手柄可以更改某些样式(请参阅此处),但我找不到适合这些的手柄。
<input class="timeBox" type="time" value="13:30"/>Run Code Online (Sandbox Code Playgroud)
在这个网站上有一个例子,说明如何在没有参数的函数上使用xpcall.但是我如何在这样的函数上使用xpcall:
function add (a, b)
return a + b
end
Run Code Online (Sandbox Code Playgroud)
它应该得到返回值.这是我的尝试(不起作用,我得到:false,错误处理错误,无):
function f (a,b)
return a + b
end
function err (x)
print ("err called", x)
return "oh no!"
end
status, err, ret = xpcall (f, 1,2, err)
print (status)
print (err)
print (ret)
Run Code Online (Sandbox Code Playgroud) 在 C++ 中,您可以使用如下代码用 0 初始化一维数组:
int myarray[100] = {0};
Run Code Online (Sandbox Code Playgroud)
多维数组有类似的方法吗?还是我被迫用 for 循环手动初始化它?
我检查sessionStorage变量是否为null,如果为true则用"BAR"初始化它.另外,应该会出现一个带有变量值的控制台消息.
sessionStorage.setItem("Foo", null); //I know this would make no sense at this part, this is just here for demo.
if (sessionStorage.getItem("Foo") == null) {
sessionStorage.setItem("Foo", "BAR");
} else {
console.log("Foo != null (proof = '", sessionStorage.getItem("Foo"), "')");
}Run Code Online (Sandbox Code Playgroud)
但是,它总是转到else语句,我得到控制台消息告诉我变量是"null",但如果它真的是"null"那么为什么它没有用"BAR"初始化?
我有一个表单,并尝试在按钮单击时删除它.
<!DOCTYPE html>
<html>
<head>
<title>test</title>
</head>
<body>
<button onclick="remove()">remove</button>
<form action="test.html" class="contactForm" dir="ltr" enctype="multipart/form-data" method="post">
<ol>
<li class="csc-form-9 csc-form-element csc-form-element-textline">
<label for="field-9">Vorname</label>
<input class="inputFormText" id="field-9" name="tx_form[firstname]" type="text"/>
</li>
<li class="csc-form-10 csc-form-element csc-form-element-textline">
<label for="field-10">Nachname</label>
<input class="inputFormText" id="field-10" name="tx_form[lastname]" type="text"/>
</li>
</ol>
</form>
<script>
function remove()
{
var x = document.getElementsByClassName("contactForm");
console.log(x);
x.remove();
}
</script>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
根据这篇文章,它应该可以通过调用remove()DOM元素来实现.但是,我得到:
(index):30 Uncaught TypeError:x.remove不是HTMLButtonElement.onclick上的删除函数((索引):30):(索引):7)
如果我多次按 Tab 来缩进某些内容,那么我总是会出现一个烦人的窗口:
这太烦人了,我怎样才能阻止它?
更新:我使用 Netbeans 8.2。
它似乎发生在.html文件和刀片模板中,但不在纯 .php 文件中。
我必须写点东西,如果我然后按 Tab 键,有时会出现一个下拉列表,如果我再次按 Tab 键,则Insert Button窗口会显示。
我尝试使用contextMenu Plugin,但我得到$.contextMenu is not a function.
我像在演示中一样尝试过。
我无法弄清楚我做错了什么。
$(function() {
$.contextMenu({
selector: '.context-menu-one',
callback: function(key, options) {
var m = "clicked: " + key;
alert(m);
},
items: {
"edit": {name: "Edit", icon: "edit"},
"cut": {name: "Cut", icon: "cut"},
copy: {name: "Copy", icon: "copy"},
"paste": {name: "Paste", icon: "paste"},
"delete": {name: "Delete", icon: "delete"},
"sep1": "---------",
"quit": {name: "Quit", icon: function(){
return 'context-menu-icon context-menu-icon-quit';
}}
}
});
$('.context-menu-one').on('click', function(e){
console.log('clicked', this);
});
});Run Code Online (Sandbox Code Playgroud)
<script
src="https://code.jquery.com/jquery-3.3.1.min.js" …Run Code Online (Sandbox Code Playgroud)javascript ×4
php ×3
html ×2
jquery ×2
laravel ×2
c++ ×1
contextmenu ×1
css ×1
curl ×1
dom ×1
html2canvas ×1
laravel-5 ×1
laravel-5.2 ×1
lua ×1
netbeans ×1