小编rah*_*aha的帖子

如何在不重置角度表单的情况下重置验证错误?

我有一个角度模板驱动的形式。我想重置所有验证错误并使其保持不变,而不重置表单。如何在角度中做到这一点?我尝试过以下方法

onAdd(form: NgForm) {

form.form.markAsPristine();
form.form.markAsUntouched();

}
Run Code Online (Sandbox Code Playgroud)

但这行不通。

链接:- https://stackblitz.com/edit/angular-ezixd4

当前行为:- 当我单击提交空表单时,所有字段都标记为错误,当我单击它时add,它会添加该字段,但上述函数不会删除错误消息。

预期行为:- 当我单击提交空表单时,所有字段都标记为错误,当我单击它时add,它会添加该字段,并且它应该删除表单上(或添加的文件中)的错误消息。

在此表单中,我使用添加按钮添加输入字段,并且我想在用户有机会与表单交互之前清除所有错误消息。

forms angular

11
推荐指数
3
解决办法
4万
查看次数

如何在flutter应用程序中flutter lottie动画?

我想在 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 使用动画?

animation flutter lottie

9
推荐指数
1
解决办法
7901
查看次数

如何让孩子在颤动中适应连续的高度?

我有一个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)

height row widget flutter

9
推荐指数
3
解决办法
9404
查看次数

Firebase 托管在部署 Angular 6 应用程序后显示欢迎页面?

我想开发 angular 6 应用程序,但在部署 firebase 后只显示欢迎页面。

以下是我为部署而采取的步骤。

  1. 安装了 firebase-tools
  2. ng build --prod(在我的应用中)
  3. 火力初始化
  4. 你准备好继续了吗?(是/否) 是
  5. (*) 托管:配置和部署 Firebase 托管站点
  6. 你想用什么作为你的公共目录?(公共)区
  7. 配置为单页应用程序(将所有 url 重写为 /index.html)?(y/N) 是
  8. 文件 dist/index.html 已经存在。覆盖?(y/N) 是
  9. Firebase 初始化完成!
  10. 在这一步中,我已经删除了 dist 文件夹并ng build --prod再次运行
  11. angular build app 在dist目录内的子文件夹中,因此我将包含 index.html 的子目录中的所有内容复制到dist/.
  12. 火力基地部署
  13. firebase 开放式主机:网站

但在完成所有这些之后,我仍然在链接中看到欢迎页面。

我究竟做错了什么!?

firebase firebase-hosting angular

8
推荐指数
2
解决办法
3513
查看次数

如何在flutter中读取本地json导入?

我在 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?

json dart flutter

8
推荐指数
1
解决办法
1万
查看次数

如何使用flutter dart中的相同元素初始化列表?

我在 dart 中有一个列表,我想用n相同元素的编号初始化列表。示例:- 用元素初始化整数列表54 次。 List<int> temp = [5,5,5,5]; 在 dart flutter 中初始化列表有哪些不同的方法?

list dart flutter

7
推荐指数
2
解决办法
1万
查看次数

如何从屏幕、反应测试库获取渲染的 HTML 元素?

在 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();这不起作用。

reactjs react-testing-library

7
推荐指数
1
解决办法
7524
查看次数

如何在颤振中创建没有标签的矩形图标按钮?

我们可以使用它创建图标按钮,FlatButton.icon()但它需要label参数。我们也可以使用IconButton(),但它制作了一个圆形图标按钮。

如何制作一个类似于矩形图标按钮FlatButton()但只有颤动图标的矩形图标按钮?

button flutter

6
推荐指数
1
解决办法
7293
查看次数

如何在flutter中使用showTimePicker作为Widget?

我希望用户选择日期和时间,因为有日期时间选择器对话框。

但是,有没有一种方法可以让我在某些颤动小部件上持续显示日期时间并像任何其他小部件一样使用?

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()用作小部件?以便其他小部件可以构建在它之上。

datetimepicker flutter

6
推荐指数
2
解决办法
4935
查看次数

无法在flutter应用程序中更改状态栏图标亮度?

在 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)

flutter flutter-layout

5
推荐指数
1
解决办法
2743
查看次数