在Vue3中使用Vue.js的TypeScript有问题,

k0pti3hp  于 2023-03-31  发布在  TypeScript
关注(0)|答案(1)|浏览(105)

如图所示,“aliyun.value [key]”会报类型错误,但我修改代码时没有任何警告,如下所示针对我的案例,更规范的写法是什么?

// Define the specific type for a ref.
const aliyun = ref<{ [key: string]: string }>({
    name: "aliyun",
    access_key_id: "",
    access_key_secret: "",
    sign_name: ""
});
wgx48brx

wgx48brx1#

const aliyun = ref<Record<string, string>>({
    name: "aliyun",
    access_key_id: "",
    access_key_secret: "",
    sign_name: ""
});

相关问题