我有一个数据“ echo json_encode ($ data ['airlines']);
”,我想将数据保存到javascript中的变量中
在javascript中
const input = {json_encode ($ data ['airlines']);}
在php中
echo json_encode($data['airlines']);
答案 0 :(得分:1)
在php中
<UserControl x:Class="CMiX.MVVM.Controls.IPBox"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" >
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition/>
<ColumnDefinition Width="0.5*"/>
<ColumnDefinition/>
<ColumnDefinition Width="0.5*"/>
<ColumnDefinition/>
<ColumnDefinition Width="0.5*"/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<TextBox
Name="txtboxFirstPart"
LostFocus="TextBox_LostFocus"
TextChanged="txtbox_TextChanged"
Grid.Column="0"
Grid.Row="0"
MaxLength="3"
TabIndex="1"
PreviewKeyDown="txtboxFirstPart_PreviewKeyDown"
/>
<Label
Content="."
Grid.Column="1"
Grid.Row="0"
/>
<TextBox
Name="txtboxSecondPart"
LostFocus="TextBox_LostFocus"
Grid.Column="2"
Grid.Row="0"
MaxLength="3"
TextChanged="txtbox_TextChanged"
TabIndex="2"
KeyDown="txtboxSecondPart_KeyDown"
/>
<Label
Content="."
Grid.Column="3"
Grid.Row="0"
/>
<TextBox
Name="txtboxThridPart"
LostFocus="TextBox_LostFocus"
Grid.Column="4"
Grid.Row="0"
MaxLength="3"
TextChanged="txtbox_TextChanged"
TabIndex="3"
KeyDown="txtboxThridPart_KeyDown"
/>
<Label
Content="."
Grid.Column="5"
Grid.Row="0"
/>
<TextBox
x:Name="txtboxFourthPart"
Grid.Column="6"
Grid.Row="0"
MaxLength="3"
TextChanged="txtbox_TextChanged"
LostFocus="TextBox_LostFocus"
TabIndex="4"
/>
</Grid>
在Java脚本中,您可以使用{!! $ airlines !!}
let isPunct = function(ch) {
let punctList = /,.;!/;
if (ch != punctList) {
return true;
} else {
return false;
}
};