我正在使用 Vue.js 和 Bootstrap 来设计一个网站。我有一个表单,我正在尝试在其上运行我的自定义验证。它工作正常,直到用户单击提交,was-validated
根据引导程序文档将类添加到表单中。
此时,无论是否满足我的自定义验证,任何具有任何输入的必填输入字段都被标记为有效并获得绿色边框和复选标记。我的自定义验证仍在运行并b-form-invalid-feedback
正确显示。但是,似乎将was-validated
具有所需属性的字段标记为有效,而没有考虑我的自定义验证,这会导致验证冲突,因为字段具有绿色复选标记(因为它满足所需的属性)但仍然是错误消息,因为根据我的自定义验证,它尚未生效。
我尝试删除:valid
样式,这不是我想要的效果,因为我确实希望它在根据我的验证有效时显示这些样式。希望这是有道理的,如果不是我会提供图片。我还有第二个问题,我有一个日期选择器,b-form-invalid-feedback
即使was-validated
添加时也根本不显示。
我的代码
<b-form @submit.prevent="addReview" name="review-form" novalidate>
<div class="name">
<label class="sr-only" for="form-input-name">Name</label>
<b-input id="form-input-name" class="form-inputs mb-2 mr-sm-2 mb-sm-0" v-model="name" placeholder="Name" required :state="isStateValid(this.name)"></b-input>
<b-form-invalid-feedback id="form-input-name">
You must enter a name
</b-form-invalid-feedback>
</div>
<div class="date">
<label class="sr-only" for="example-datepicker">Choose a date</label>
<b-form-datepicker id="datepicker" v-model="dateVisited" class="mb-2" required placeholder="Date Visited" :state="isStateValid(this.dateVisited)"></b-form-datepicker>
<b-form-invalid-feedback id="datepicker">
You must enter a valid date
</b-form-invalid-feedback>
</div>
<div class="service">
<label class="sr-only" for="form-input-service">Service Provided</label>
<b-input …
Run Code Online (Sandbox Code Playgroud) 我知道这个问题已经被问了很多,我花了很多时间阅读并尝试实现答案。所以我试图让isEmailVerified
Firebase Auth的响应工作并且它确实工作但现在它总是返回 false 除非我刷新应用程序或关闭它并重新打开它。这显然是一种糟糕的用户体验。如何在无需关闭应用程序的情况下获得更新响应。
这是相关的代码片段。
Future<bool> isEmailVerified() async {
FirebaseUser user = await _auth.currentUser();
if (user == null) {
return false;
} else {
await user.reload();
user = await _auth.currentUser();
return user.isEmailVerified;
}
}
Run Code Online (Sandbox Code Playgroud)
main.dart
child: Consumer<Auth>(
builder: (_, auth, __) => MaterialApp(
theme: Provider.of<ThemeNotifier>(context).getTheme(),
home: FutureBuilder(
future: Future.wait([auth.isEmailVerified(), auth.tryAutoLogin()]),
builder: (BuildContext ctx, AsyncSnapshot authResultSnapshot) =>
authResultSnapshot.connectionState == ConnectionState.done
? authResultSnapshot.data[1]
? authResultSnapshot.data[0]
? HearingsScreen()
: SplashScreen(
emailVerified: true,
)
: LoginScreen()
: SplashScreen(),
),
Run Code Online (Sandbox Code Playgroud)
在我重新启动应用程序之前它不会返回 true
除了这个之外我还尝试过的事情: …