作为 Typescript 新手,我尝试尽可能准确地输入所有内容,作为学习过程的一部分。
\n我有一个lqip来自 CMS 的(低质量图像占位符)属性,它应该是 base64 编码的图像。它显然是一个字符串,但将其作为字符串输入感觉有点不精确。
mainImage: Schema.Post["mainImage"] & {\n // can I be more precise? It should be always a base64 encoded image, not just a generic string\xe2\x80\xa6\n // e.g. "data:image/jpeg;base64,/9j/2wBDAAYEB\xe2\x80\xa6"\n lqip: string\n}\nRun Code Online (Sandbox Code Playgroud)\nTypescript 中有 Base64 编码图像的类型吗?我尝试广泛搜索谷歌,但我只找到了有关atob/btoa转换的主题,而不是类型本身。谢谢!
假设我有这个C#类别
public class Product
{
public Guid Id { get; set; }
public string ProductName { get; set; }
public Decimal Price { get; set; }
public int Level { get; set; }
}
Run Code Online (Sandbox Code Playgroud)
等效的打字稿如下所示:
export class Product {
id: ???;
productName: string;
price: number;
level: number;
}
Run Code Online (Sandbox Code Playgroud)
如何在打字稿中代表Guid?