我是一名初级开发人员,遇到了这样的问题:Laravel给我带来了一个错误:"使用未定义的常量输入-假设'input'"我不明白为什么:这个变量是在javascript代码。
在这里:
<div class="form-group">
{!! Form::label('pac-input', 'Адрес') !!}
{!! Form::text('pac-input', $meta ? $meta->pac-input:old('pac-input', null), ['class' => 'form-control', 'placeholder' => 'Введите адрес']) !!}
</div>
我输入var input = (
document.getElementById('pac-input'));
var autocomplete = new google.maps.places.Autocomplete(input);
autocomplete.bindTo('bounds', map);
My JavaScript code (google.maps.api3)
也有一个问题:在源代码中,
后面有一个注释var input = /** @type {!HTMLInputElement} */(
document.getElementById('pac-input'));
这个人想要什么样的HTMLInputElement
?
谢谢!
你的代码中有一个打字错误。
代替$meta->pac-input
$meta->pac->input
这里的罪魁祸首是-
Laravel blade模板将变量$meta->pac-input
视为$meta->pac
和-input
,而不是$meta->pac-input
作为单个变量。
你可能想把你的代码改成
<div class="form-group">
{!! Form::label('pac_input', 'Адрес') !!}
{!! Form::text('pac_input', $meta ? $meta->pac_input:old('pac_input', null), ['class' => 'form-control', 'id' => 'pac_input' 'placeholder' => 'Введите адрес']) !!}
</div>