Syntax Error: TypeError: Cannot read properties of undefined (reading 'spaces') npm run serve vue

vltsax25  于 2022-12-13  发布在  其他
关注(0)|答案(1)|浏览(850)

Hi i'm facing somewhat a strange problem during $npm run serve

here is my page structure

<template>
  <div>
    ...
  </div>
</template>

<script>
export default {
   name: 'game',
   ...
}
</script>

<style lang="scss" scoped>
 $variable1:#fff;
 ....
</style>

My package.json looks something like this

"devDependencies":{
    "node-sass": "^6.0.0",
    "sass-loader": "^10.1.0",
    "vue-loader-v16": "npm:vue-loader@^16.1.1"
}
axzmvihb

axzmvihb1#

通常,当您尝试访问(尚)不存在的对象的属性时,会发生此类错误。
因此,我认为在代码中的某个地方,您试图访问someObject.spaces,但someObject未定义。为了避免这种情况,您可以在操作之前添加一个简单的if子句:

if(someObject){
  doSomething(someObject.spaces)
}

不过,我认为您必须填写更多的代码才能确定到底发生了什么。

相关问题