我有一个登记表,使用vue在Laravel刀片文件。对于用户的无效输入,我使用了一个验证器,我希望得到这个字段的旧值,但是现在我无法使它工作,因为其中一些字段正在使用vue。这是我的密码:
regist.blade.php
<div class="regist_input">
<input type="email" name="email" v-model="email" v-bind:placeholder="placeholder_email" v-bind:class="{ error: emailError }">
<p class="error_text" v-bind:class="{ active: emailError2 }">Invalid email.</p>
@if($errors->has('email'))
<p class="alert-error">
{{ $errors->first('email') }}
</p>
@endif
</div>
<dd>
<div class="regist_input">
<input class="input_company" type="text" name="company" value="{{ old('company') }}" placeholder="company"> //this one works
</div>
</dd>控制器
if($validator->fails()) {
return redirect()->back()->withInput()->withErrors($validator->errors());
}如果在字段的外面,我可以显示它的旧值,这意味着我的php验证函数正在工作。
我试过使用v-bind:value="{{ old('email') }}"或:value="{{ old('email') }}",但不是working.For,如何在具有vue组件的输入字段中显示旧值?
发布于 2019-04-11 03:36:45
v-bind:value="{{ old('email') }}"或:value="{{ old('email') }}不能工作,因为您使用的是v-model="email"
当您使用v模型时,这意味着在Vue组件的"data“属性中应该有一个"email”属性,而设置到该"email“属性的任何值都将显示为输入字段的值。
我创建了看这支钢笔来说明这两种情况。
因此,如果要使用v-bind:value,则需要删除v-模型。现在我正在写这篇文章,我认为您不需要使用v-bind:value,只需简单地使用value (就像您使用公司输入一样)。
https://stackoverflow.com/questions/55624061
复制相似问题