我是 React 的新手。我在 Laravel 刀片中部分使用了反应表单组件。那么如何将验证错误消息从控制器发送到驻留在 Laravel 刀片文件中的反应组件。
在我的控制器中,
public function store(Request $request)
{
$rules = [
'name' => 'required',
'publish_at' => 'required|datetime'
];
$this->validate($request, $rules);
$book = Book::create([
'name' => $request->name,
'publish_at' => $request->publish_at
]);
return response()->json($book);
}
Run Code Online (Sandbox Code Playgroud)
在我的 Laravel 刀片中,
<form method="POST" action="patients">
@csrf
<div class="form-group">
<label for="name">Name</label>
<input type="text" name="name" class="form-control" placeholder=". . .">
@error('name')
<span class="text-danger">{{ $message }}</span>
@enderror
</div>
<div id="publish_at"></div> <!-- this is react component -->
<button type="submit">Submit</button>
</form>
Run Code Online (Sandbox Code Playgroud) 在我的 UWP 应用程序中,我尝试将导航视图扩展到标题栏。但问题是它没有到达标题栏,如下所示。
我想要的是像下面这样的。
您可以看到“XAML 控件库”和后退按钮位于最上面的位置,在我的例子中它们位于下方。我想将“学生管理”放置在后退按钮旁边,如第二张图片所示。
下面是我的代码。
应用程序.xaml.cs
OnLaunched () {
// entends views to the title bar
var coreTitleBar =
Windows.ApplicationModel.Core.CoreApplication.GetCurrentView().TitleBar.ExtendViewIntoTitleBar = true;
ApplicationViewTitleBar titleBar = ApplicationView.GetForCurrentView().TitleBar;
titleBar.ButtonBackgroundColor = Colors.Transparent;
titleBar.ButtonInactiveBackgroundColor = Colors.Transparent;
}
Run Code Online (Sandbox Code Playgroud)
主页.xaml
<Page
x:Class="HelloWorld.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:HelloWorld"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
Background="{StaticResource NavigationViewExpandedPaneBackground}"
>
<Grid x:Name="AppTitleBar" Background="Transparent">
<Grid.Resources>
<AcrylicBrush x:Key="NavigationViewExpandedPaneBackground"
BackgroundSource="HostBackdrop"
TintColor="AliceBlue"
TintOpacity="0.6"
FallbackColor="White"/>
</Grid.Resources>
<NavigationView
x:Name="navView"
IsBackEnabled="True"
Loaded="NavigationView_Loaded"
SelectionChanged="NavigationView_SelectionChanged"
PaneOpening="navView_PaneOpening"
IsBackButtonVisible="Visible"
SelectionFollowsFocus="Disabled"
Header="Students"
PaneDisplayMode="Auto"
Background="{StaticResource SystemChromeWhiteColor}"
OpenPaneLength="280" UseLayoutRounding="True" ScrollViewer.VerticalScrollBarVisibility="Auto" FontSize="12" PaneTitle="Student Management"
>
<NavigationView.MenuItems>
<NavigationViewItem Icon="People" …Run Code Online (Sandbox Code Playgroud)