Open utterances-bot opened 2 years ago
有个问题哈,为什么不可以在scr/composables/formattedTime.js
中这样写呢?
export default function formattedTime () {
const formatted_time = (iso_date_string) => {
return formatted(iso_date_string)
}
return {
formatted_time
}
}
function formatted (iso_date_string) {
const date = new Date(iso_date_string);
return date.toLocaleDateString();
}
然后在ArticleList.vue
的setup()
中这样调用呀:const formatted_time = formattedTime();
我这样写会报这个错:
Uncaught (in promise) TypeError: $setup.formatted_time is not a function
at eval (ArticleList.vue?64e5:21:1)
at renderList (runtime-core.esm-bundler.js?5c40:2884:1)
at Proxy.render (ArticleList.vue?64e5:2:1)
at renderComponentRoot (runtime-core.esm-bundler.js?5c40:896:1)
at ReactiveEffect.componentUpdateFn [as fn] (runtime-core.esm-bundler.js?5c40:5651:1)
at ReactiveEffect.run (reactivity.esm-bundler.js?a1e9:185:1)
at instance.update (runtime-core.esm-bundler.js?5c40:5694:1)
at callWithErrorHandling (runtime-core.esm-bundler.js?5c40:155:1)
at flushJobs (runtime-core.esm-bundler.js?5c40:396:1)
(保证不是命名错误这种低级bug)
Django-Vue搭建个人博客:组合式API - 杜赛的博客
https://www.dusaiphoto.com/article/134/