我有一个角度模板驱动的形式。我想重置所有验证错误并使其保持不变,而不重置表单。如何在角度中做到这一点?我尝试过以下方法
onAdd(form: NgForm) {
form.form.markAsPristine();
form.form.markAsUntouched();
}
Run Code Online (Sandbox Code Playgroud)
但这行不通。
链接:- https://stackblitz.com/edit/angular-ezixd4
当前行为:-
当我单击提交空表单时,所有字段都标记为错误,当我单击它时add,它会添加该字段,但上述函数不会删除错误消息。
预期行为:-
当我单击提交空表单时,所有字段都标记为错误,当我单击它时add,它会添加该字段,并且它应该删除表单上(或添加的文件中)的错误消息。
在此表单中,我使用添加按钮添加输入字段,并且我想在用户有机会与表单交互之前清除所有错误消息。
我想在 flutter 应用程序中为 Lottie 文件设置动画。我尝试搜索互联网的每个角落,但未能找到任何相关信息。
我发现有一个flutter包“flutter_lottie.dart”并且有一个动画功能。
作者还提供了一个例子来说明使用 flutter_lottie.dart
但这我尝试运行确切的示例:flutter Lottie example
它给出了同样的错误:
Creating Method Channel convictiontech/flutter_lottie_0
E/flutter (11371): [ERROR:flutter/shell/common/shell.cc(199)] Dart Error: Unhandled exception:
E/flutter (11371): PlatformException(error, java.lang.IllegalStateException: Unable to parse
composition
E/flutter (11371): at com.airbnb.lottie.LottieAnimationView$2.onResult(LottieAnimationView.java:68)
Run Code Online (Sandbox Code Playgroud)
如何在颤振中使用 Lottie 使用动画?
我有一个Row带有输入文件和搜索按钮的小部件。行位于列内。
如何使搜索按钮适合行的高度,使按钮大小等于输入字段的高度?
我尝试添加crossAxisAlignment: CrossAxisAlignment.stretch,到行但收到错误:-
BoxConstraints forces an infinite height.
我没有输入字段的高度。并且不想对按钮的高度进行硬编码,因为它应该始终与输入框的高度匹配。
此外,将高度分配给行并添加CrossAxisAlignment.stretch不会更改输入字段的高度,唯一的按钮正在更改。
这里有什么问题以及如何解决这个问题?
Row(
// crossAxisAlignment: CrossAxisAlignment.stretch,
mainAxisAlignment: MainAxisAlignment.center,
children: [
Expanded(
child: Container(
child: TextField(
decoration: InputDecoration(
border: InputBorder.none,
hintText: 'search',
hintStyle:
Theme.of(context).textTheme.bodyText2.copyWith(
color: Theme.of(context).accentColor,
),
contentPadding: EdgeInsets.symmetric(
vertical: 8, horizontal: 20
),
fillColor: Theme.of(context).primaryColor,
filled: true,
),
style: Theme.of(context).textTheme.bodyText2,
),
),
),
FlatButton(
onPressed: () {},
color: Colors.grey,
child: Icon(
Icons.search,
),
),
],
)
Run Code Online (Sandbox Code Playgroud) 我想开发 angular 6 应用程序,但在部署 firebase 后只显示欢迎页面。
以下是我为部署而采取的步骤。
ng build --prod再次运行dist目录内的子文件夹中,因此我将包含 index.html 的子目录中的所有内容复制到dist/.但在完成所有这些之后,我仍然在链接中看到欢迎页面。
我究竟做错了什么!?
我在 flutter 目录中有一个 JSON 文件,而不是资产中。
json_data.json:-
{
"foo" : "bar"
}
Run Code Online (Sandbox Code Playgroud)
我想在不同的文件上阅读这个 JSON。
喜欢
myfile.dart:-
import "package:mypackage/json_data.json" as data;
import 'dart:convert';
var my_data = json.decode(data);
Run Code Online (Sandbox Code Playgroud)
我收到错误:-
The name 'data' refers to an import prefix, so it must be followed by '.'.
Try correcting the name to refer to something other than a prefix, or renaming the prefix.
Run Code Online (Sandbox Code Playgroud)
这里有什么问题?为什么我不能在颤振中从本地导入读取 JSON?
我在 dart 中有一个列表,我想用n相同元素的编号初始化列表。示例:- 用元素初始化整数列表54 次。
List<int> temp = [5,5,5,5];
在 dart flutter 中初始化列表有哪些不同的方法?
在 React 测试库中,我想从屏幕获取整个渲染的 HTML,并检查它是否正确渲染并存在于 dom 中。
我看到屏幕有查询 DOM 的方法,但如何访问呈现的完整 HTML。
import React from 'react';
import {render, screen} from '@testing-library/react';
import '@testing-library/jest-dom';
import {server} from '../__mock__/server.mock';
import InfoBar from '../Components/infoBar';
beforeAll(() => server.listen());
afterEach(() => server.resetHandlers());
afterAll(() => server.close());
test('InfoBar renders correctly.', async () => {
render(<InfoBar/>);
expect(screen).toBeInTheDocument();
});
Run Code Online (Sandbox Code Playgroud)
expect(screen).toBeInTheDocument();这不起作用。
我们可以使用它创建图标按钮,FlatButton.icon()但它需要label参数。我们也可以使用IconButton(),但它制作了一个圆形图标按钮。
如何制作一个类似于矩形图标按钮FlatButton()但只有颤动图标的矩形图标按钮?
我希望用户选择日期和时间,因为有日期时间选择器对话框。
但是,有没有一种方法可以让我在某些颤动小部件上持续显示日期时间并像任何其他小部件一样使用?
Container(
child: showTimePicker(
context: context,
initialTime: TimeOfDay.now(),
builder: (BuildContext context, Widget child) {
return Theme(
data: ThemeData.dark(),
child: child,
);
},
);
}
Run Code Online (Sandbox Code Playgroud)
但我不能showTimePicker用作小部件。
如何showTimePicker()用作小部件?以便其他小部件可以构建在它之上。
在 main.dart
void main() {
SystemChrome.setSystemUIOverlayStyle(
SystemUiOverlayStyle(
statusBarColor: Colors.black.withOpacity(0), //top bar color
statusBarIconBrightness: Brightness.dark, //top bar icons
systemNavigationBarColor: Colors.black, //bottom bar color
systemNavigationBarIconBrightness: Brightness.light, //bottom bar icons
),
);
runApp(MyApp());
}
class MyApp extends StatelessWidget {
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
return MaterialApp(
theme: ThemeData(
//primaryColor: Color.fromRGBO(113, 201, 206, 1),
fontFamily: 'Montserrat',
textTheme: TextTheme(
headline: TextStyle(
fontSize: 40,
fontWeight: FontWeight.w500,
),
title: TextStyle(
fontWeight: FontWeight.w700,
fontSize: 16,
),
body1: TextStyle(
fontSize: …Run Code Online (Sandbox Code Playgroud)