我已经构建了一个包含一个人的4个属性的表单:
firstName, lastName, email, mobile
该表单可以在应用程序中的许多地方使用。我看到的所有教程都显示了可重用组件,但只显示为相关父级的子组件。例如:
/customers <- renders a list of customers, select one and
/customers/1 <- renders a customer detail, with a customer form
但如果我也有:
/contacts <- renders a list of contacts
/contact
我刚刚开始学习React,正在为条件渲染而苦苦挣扎。我想基于表单输入来呈现组件,但是我不确定需要做什么或者需要在哪里执行。
我已经导入了我的表单组件,该组件具有我想要使用的输入,并具有另一个类似如下的组件:
import React, {Component} from 'react';
import Form from './Form';
import CardOne from './CardOne';
import CardTwo from './CardTwo';
import CardThree from './Ca
我的Blazor应用程序在不同的组件中有两个表单。这两种形式使用相同的视图模型。尽管模型是相同的,但组件中显示了不同的字段。例如,第一个组件的表单没有UnitPrice字段,但第二个组件有。我使用一个简单的验证:
[Required(ErrorMessage = "Unit Price is required.")]
[Range(0.01, double.MaxValue, ErrorMessage = "Unit Price must be greater than 0")]
public double UnitPrice { get