typescript - 如何使用打字稿在 vuejs 中的数据中添加“文件”类型?
问题描述
我的代码:
interface Item {
title: string;
type: string;
description: string;
}
data() {
return {
id: "",
item: {} as Item,
file: //Here
};
}
您好,我正在寻找向我的 vuejs 数据添加文件类型。
我看到了这个可行的解决方案:
interface Item {
title: string;
type: string;
description: string;
file: File;
}
data() {
return {
id: "",
item: {} as Item
};
}
但我不想将我的数据文件添加到我的 Item 界面或对象中。
解决方案
您可以将interface
( 或type
) 写入数据本身,然后将file
属性添加到其中。
interface Item {
title: string;
type: string;
description: string;
}
interface State {
id: string;
item: Item;
file: null | File;
}
data(): State {
return {
id: '',
item: {
title: '',
type: '',
description: '',
},
file: null,
};
},
推荐阅读
- pyspark - pyspark 将字符串数组转换为 Map()
- javascript - 获取动态手风琴jquery的索引
- c++ - 将字符串字节与 char c++ 进行比较
- asp.net -
不是成员 发布到 Azure 时出错 - node.js - 在nodejs中发送回复
- php - 高质量的图像输出在 php 和 mysql 中变得修剪
- xquery - 在 Marklogic 中将 XCC 调用替换为 Rest 调用
- c# - 如何使用输入(文本)控件将日期值从日期选择器存储到数据库中
- botframework - MS 机器人回复两次
- javascript - 如何根据输入的数字使进度条值增加