我想让我的 matInput 小于默认大小。html 看起来像这样:
<mat-form-field class="input-parent" subscriptSizing="dynamic" appearance="outline" style=" margin-right: 10px; font-size: 12px;">
<input matInput type="text" [(ngModel)]="input" (keydown)="checkForSubmit($event)">
</mat-form-field>
Run Code Online (Sandbox Code Playgroud)
在scss中,我遵循了这个 答案,并添加了以下scss:
.input-parent{
@include mat.input-density(-2);
}
Run Code Online (Sandbox Code Playgroud)
但是,它根本不影响输入的大小。我也尝试过类似的东西
-mat.all-component-densities代替mat.input-density
将其移出类到主 scss 文件
将其放在 body 中而不是 .input-parent
将父类设置为 的父类mat-form-field而不是 的直接父类mat-input
但没有任何效果。我还想补充一点,改变按钮的密度是有效的,但改变输入的密度却不起作用。
有没有人有办法解决吗?谢谢
我有一个非常简单的问题。当我尝试统一构建游戏时出现构建错误。当我在编辑器中运行游戏时,它工作得很好。这是控制台中显示的错误。
Assets\Scripts\Pattern.cs(284,17): error CS0103: The name 'EditorUtility' does not exist in the current context
Run Code Online (Sandbox Code Playgroud)
现在,这是错误引用的代码行:
EditorUtility.DisplayDialog("Great!", "You got the pattern right!", "Next Level!");
Run Code Online (Sandbox Code Playgroud)
最后,如果您认为错误是我没有将正确的内容导入脚本,那么您错了,因为我导入了这个:
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using System;
using UnityEditor;
Run Code Online (Sandbox Code Playgroud)
有谁能够帮助我?先感谢您。
编辑:做这个代码:
#if UNITY_EDITOR
EditorUtility.DisplayDialog("Meh", "You got the pattern wrong ):", "Try Again!");
#endif
Run Code Online (Sandbox Code Playgroud)
不起作用。在构建版本中,它只是不显示消息框,它的行为就好像这一行只是一个注释。有人可以帮忙吗?
我正在使用我自己的自定义堆栈类,并且我正在尝试创建用于创建新堆栈(通用对象)的通用方法。我经常使用 int 类型的堆栈,只是偶尔需要其他类型的堆栈。我可以将 T 的默认类型设置为 int 吗?
这是方法:
public static Stack<T> newStack<T>(int length)
{
Stack<T> s = new Stack<T>();
for (int i = 0; i < length; i++)
{
Console.WriteLine("print num");
string input = Console.ReadLine();
T value = (T)Convert.ChangeType(input, typeof(T));
s.Push(value);
}
return s;
}
Run Code Online (Sandbox Code Playgroud)
我想使用这样的方法:
newStack(5);//defult int type
Run Code Online (Sandbox Code Playgroud)
对于任何其他类型
newStack<string>(5)
Run Code Online (Sandbox Code Playgroud)
有人可以帮忙吗?谢谢。