You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Vue.js在mounted中调用方法报_this.deneme is not a function错误

错误原因及解决方案

核心错误点

  • 配置项拼写错误:Vue组件的方法配置项固定为methods,你的代码中误写为methotds,拼写错误会导致Vue无法将定义的deneme方法挂载到组件实例上,因此this.deneme是未定义值,调用时自然会抛出「不是函数」的错误
  • 语法格式错误:mounted函数定义结束后多写了多余的右括号),不符合对象属性的语法规范,会导致组件配置整体解析异常

修正后的代码

async mounted() {
    await this.deneme()
},
methods: {
    deneme() {
        console.log("it's working")
    }    
}

你之前移除async/await后问题没有解决,是因为问题根源和异步语法无关,只要修正上述两个错误即可正常运行。

内容的提问来源于stack exchange,提问作者sssss_sssss

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.10.04 16:15:03