云计算百科
云计算领域专业知识百科平台

Uncaught (in promise) TypeError: x.isoWeek is not a function

在 vue3 项目开发中,引入 dayjs 插件后,使用 isoWeek() 浏览器提示错误:

Uncaught (in promise) TypeError: x.isoWeek is not a function

解决方案

要想使用 isoWeek() API,就需要引入插件扩展包(dayjs/plugin/isoWeek),如下代码(引入+使用)所示:

// 引入基础包
import dayjs from 'dayjs'

// 引入并初始化 "周处理" 的扩展包
import isoWeek from 'dayjs/plugin/isoWeek'
dayjs.extend(isoWeek)

const today = dayjs();
const currentWeekNumber = today.isoWeek();
console.log(`Current week number (ISO): ${currentWeekNumber}`);

赞(0)
未经允许不得转载:网硕互联帮助中心 » Uncaught (in promise) TypeError: x.isoWeek is not a function
分享到: 更多 (0)

评论 抢沙发

评论前必须登录!