【发布时间】:2021-10-16 21:52:51
【问题描述】:
在这篇 SO 帖子中,展示了如何向 Vue 应用程序添加简单的配置,
上面的答案使用下面的JS代码。
fetch(process.env.BASE_URL + "config.json")
.then((json) => {
json().then((config) => {
Vue.prototype.$config = config
new Vue({
router,
store,
render: (h) => h(App)
}).$mount("#app")
})
})
我将其放入我的 TS 代码中,并得到以下错误。
D:/TFS/StudentPortal4Vue/clientapp/src/main.ts(44,13) 中的错误:44:13 此表达式不可调用。类型“响应”没有调用 签名。 42 | .then((json) => 43 | {
44 | json().then((配置) => | ^ 45 | { 46 | Vue.prototype.$config = 配置; 47 |新的 Vue({ 版本:打字稿 4.3.2
对我来说很明显我有类型问题,但我不知道如何解决它。
(在 ts 上超级新,在 JS 和 Vue 上老但不成熟)
【问题讨论】:
标签: javascript typescript vuejs2