未定义常量(输入)的使用


Use of undefined constant (input) laravel 5

我是一名初级开发人员,遇到了这样的问题: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>