我正在尝试使用角度材料2创建一个导航栏,它在移动设备和平板电脑等小屏幕中折叠.我只能找到md-button而不是md-menu-bar,就像在角度材料中一样
我的组件中的一些功能打开或关闭取决于浏览器大小因此我想检查调整大小事件上的浏览器宽度,但我可以使用On Init方法,但我需要刷新浏览器调整大小时发生更新浏览器宽度
ngOnInit() {
if (window.innerWidth <= 767){
---- do something
}
}
Run Code Online (Sandbox Code Playgroud)
但是我试图使用OnChanges方法,但它也不起作用
OnChanges(changes:SimpleChanges){
console.log( 'width:====>' + changes[window.innerWidth].currentValue);
if ( changes[window.innerWidth].currentValue <= 767 ){
---- do something
}
Run Code Online (Sandbox Code Playgroud)
}
有任何建议或替代方法来实现这一目标吗?
我正在尝试设计在小屏幕中折叠的响应式菜单栏,但是,我正在使用打字稿.是否有任何线索与打字稿中的此代码等效
function myFunction() {
document.getElementsByClassName("topnav")[0].classList.toggle("responsive");}
Run Code Online (Sandbox Code Playgroud)
我在打字稿中更改为此代码,但它永远不会有效
myFunction(): void {
(<HTMLScriptElement[]><any>document.getElementsByClassName("topnav"))[0].classList.toggle("responsive");
}
Run Code Online (Sandbox Code Playgroud) 我试图*ngIf在Angular 2中使用编程方式设置按钮名称
我的html模拟看起来像这样
<button type="button" class="btn btn-primary" style="margin-top:5px;" (click)="setDefaultAttachment(img.id)" *ngIf ="defaultAttaschmentId === img.id ? buttonName ='Default Image' : buttonName ='Set As Default'" > {{buttonName}}</button>
Run Code Online (Sandbox Code Playgroud)
我的setDefaultAttachment方法看起来像这样:
setDefaultAttachment (id:number){
this.defaultAttaschmentId = id ;
}
Run Code Online (Sandbox Code Playgroud)
但我收到这个错误:
EXCEPTION:错误:未捕获(在承诺中):模板解析错误:解析器错误:绑定不能包含[ngIf defaultAttaschmentId === img.id中第52列的赋值?在AttachmentsTabComponent @ 29:126中buttonName ='Default Image':buttonName ='Set As Default']("pe ="button"class ="btn btn-primary"style ="margin-top:5px;"(click)= "setDefaultAttachment(img.id)"[ERROR - >]*ngIf ="defaultAttaschmentId === img.id?buttonName ='Default Image':buttonName ='Set As Default'""):AttachmentsTabComponent @ 29:126***
我如何组合伪元素,如:after和伪类,:hover和:not?
li {
margin-bottom: 10px;
}
li:after {
content: '';
display: block;
width: 0;
height: 3px;
background: #009688;
transition: width .8s;
}
li:hover:after {
width: 100%;
}Run Code Online (Sandbox Code Playgroud)
<ul>
<li>first</li>
<li>second</li>
<li>third</li>
<li>forth</li>
<li>fifth</li>
</ul>Run Code Online (Sandbox Code Playgroud)
例如,如何从此悬停效果中排除列表中的第一个和第三个项目?
我在加载为DataFrame的数据集中使用ExtraTreesClassifier和SelectFromModel执行功能选择,但是我想将这些选定的功能作为DataFrame保存到csv文件,同时保留列名.注意输出是numpy数组返回重要功能整列而不是列标题
import pandas as pd
from sklearn.ensemble import ExtraTreesClassifier
from sklearn.feature_selection import SelectFromModel
import numpy as np
df = pd.read_csv('los_10_one_encoder.csv')
y = df['LOS'] # target
X= df.drop('LOS',axis=1) # drop LOS column
clf = ExtraTreesClassifier()
clf = clf.fit(X, y)
print clf.feature_importances_
model = SelectFromModel(clf, prefit=True)
X_new = model.transform(X)
Run Code Online (Sandbox Code Playgroud) 我正在从终端接受问题并通过对话框发送回复,但我的程序只接受第一个输入并重复。
例如,当我运行我的脚本时,输出可能是这样的:
[Eliza]: Hi, I'm a psychotherapist. What is your name?
user Input: hello my name is adam.
[Eliza]: hello adam, how are you?
[Eliza]: your name is adam
[Eliza]: your name is adam
[Eliza]: your name is adam
[Eliza]: your name is adam
[Eliza]: your name is adam
Run Code Online (Sandbox Code Playgroud)
它无休止地重复。
我不知道我哪里做错了。如何让我的程序从键盘读取下一行?
sub hello {
print "[Eliza]: Hi, I'm a psychotherapist. What is your name? \n";
}
sub getPatientName {
my ($reply) = @_;
my @responses …Run Code Online (Sandbox Code Playgroud) 尝试提取匹配string中pattern的子串.例如,我有类似下面的文本
[ Pierre/NNP Vinken/NNP ]
,/,
[ 61/CD years/NNS ]
old/JJ ,/, will/MD join/VB
[ the/DT board/NN ]
as/IN
[ a/DT nonexecutive/JJ director/NN Nov./NNP 29/CD ]
./.
[ Mr./NNP Vinken/NNP ]
is/VBZ
[ chairman/NN ]
of/IN
Run Code Online (Sandbox Code Playgroud)
我想在斜杠(/)和斜杠之后提取任何东西,但不知何故,我的正则表达式提取第一个子字符串并忽略该行中的其余子字符串.
我的输出如下所示:
tag:Pierre/NNP Vinken - word:Pierre/NNP Vinken/NNP ->1
tag:, - word:,/, ->1
tag:61/CD years - word:61/CD years/NNS ->1
tag:old/JJ ,/, will/MD join - word:old/JJ ,/, will/MD join/VB ->1
tag:the/DT board - word:the/DT board/NN ->1
tag:as - word:as/IN ->1
tag:a/DT nonexecutive/JJ director/NN Nov./NNP 29 - …Run Code Online (Sandbox Code Playgroud) 我使用angular-cli设置了角度2项目,它对我有效.有什么方法可以将这个项目添加到visual studio中的asp.net核心
我有两个流,我想将它们组合成不同的列表,即我有哈希映射
Map<String, List<String>> citiesByZip = new HashMap<>();
Run Code Online (Sandbox Code Playgroud)
持有这些数据
Alameda [95246, 95247]
Colusa [95987]
Run Code Online (Sandbox Code Playgroud)
人员名单
class Person {
private String firstName;
private String lastName;
private int income;
private int zipCode;
People(String firstName, String lastName, int income, int zipCode) {
this.firstName = firstName;
this.lastName = lastName;
this.income = income;
this.zipCode = zipCode;
}
public String getFirstName() {
return firstName;
}
public String getLastName() {
return lastName;
}
public int getIncome() {
return income;
}
public int getZipCode() {
return zipCode;
}
} …Run Code Online (Sandbox Code Playgroud) 我正在使用tensorflow 2.0 API,其中我从所有图像路径创建了一个数据集,如下例
X_train, X_test, y_train, y_test = train_test_split(all_image_paths, all_image_labels, test_size=0.20, random_state=32)
path_train_ds = tf.data.Dataset.from_tensor_slices(X_train)
image_train_ds = path_train_ds.map(load_and_preprocess_image, num_parallel_calls=AUTOTUNE)
Run Code Online (Sandbox Code Playgroud)
但是,当我运行此代码以使用keras ImageDataGenerator应用某些参数时,出现错误
datagen=tf.keras.preprocessing.image.ImageDataGenerator(featurewise_center=True,
featurewise_std_normalization=True,
rotation_range=20,
width_shift_range=0.2,
height_shift_range=0.2,
horizontal_flip=True)
datagen.fit(image_train_ds)
Run Code Online (Sandbox Code Playgroud)
错误:
/usr/local/lib/python3.6/dist-packages/keras_preprocessing/image/image_data_generator.py in fit(self, x, augment, rounds, seed)
907 seed: Int (default: None). Random seed.
908 """
--> 909 x = np.asarray(x, dtype=self.dtype)
910 if x.ndim != 4:
911 raise ValueError('Input to `.fit()` should have rank 4. '
/usr/local/lib/python3.6/dist-packages/numpy/core/numeric.py in asarray(a, dtype, order)
499
500 """
--> 501 return array(a, dtype, copy=False, …Run Code Online (Sandbox Code Playgroud) angular ×4
perl ×2
angular-cli ×1
asp.net-core ×1
css ×1
css3 ×1
events ×1
java-8 ×1
java-stream ×1
keras ×1
pseudo-class ×1
python ×1
regex ×1
scikit-learn ×1
typescript ×1