【问题标题】:"Cannot read property 't' of undefined" error when using vuetify v-carousel component使用 vuetify v-carousel 组件时出现“无法读取未定义的属性 't'”错误
【发布时间】:2019-12-25 09:23:13
【问题描述】:

我目前正在使用 Laravel 和 Vue/Vuetify 制作图像轮播,我正在使用 Vuetify v-carousel 和 v-carousel-item 来实现这一点,除了轮播由于错误而无法呈现标题。

我已经根据 vuetify 文档正确初始化了我的 Vuetify 实例(我认为)

--下面的代码是我的 app.js--

import Vue from 'vue'
import Vuetify, {VCarousel} from 'vuetify/lib'

Vue.component('example-component', require('./components/ExampleComponent.vue').default);

Vue.use(Vuetify, {
    components: {
      VCarousel,
    },
  })

// export default new Vuetify({})

const app = new Vue({
}).$mount('#app');

--下面的代码是针对使用轮播的组件--

<template>
    <v-carousel>
      <v-carousel-item v-for="(slide, i) in slides" :src = "slide.content " :key=i>
      </v-carousel-item>
      <v-carousel-item>
          <!-- <v-playback autoPlay :url = "video" :type="video/mp4" :width = "720" @play = "pauseCarousel" @pause = "playCarousel" ref = 'videoPlayer'></v-playback> -->
      </v-carousel-item>
    </v-carousel>
</template>

这给了我这个错误

[Vue warn]: Error in render: "TypeError: Cannot read property 't' of undefined"

found in

---> <VCarousel>
       <ImageCarousel> at resources/js/components/ImageCarousel.vue
         <ExampleComponent> at resources/js/components/ExampleComponent.vue
           <Root>

【问题讨论】:

  • 您收到此错误是因为您可能使用了 firefox。切换到chrome,你会得到一个real错误信息。
  • 另外,当您在生产环境中构建项目时,您可能会收到Cannot read property 一些字母of undefined

标签: javascript laravel vue.js vuetify.js


【解决方案1】:

我将继续假设您使用的是 firefox

使用 vuetify v-carousel 组件时出现“Cannot read property 't' of undefined”错误

这种类型的错误通常在 中发现,因为它无法正确读取已转译项目的源映射,从而产生该错误。

我在 typescript 项目中遇到了同样的问题。

我建议(暂时)切换到 进行调试,这将为您提供更详细的真实错误消息。

【讨论】:

  • 感谢所有答案,但我设法通过启动一个新项目然后手动导入该项目所需的所有组件来使一切正常。现在一切正常,但是我在这里遇到了另一个问题:stackoverflow.com/questions/57605363/…
猜你喜欢
  • 2020-01-24
  • 2020-07-12
  • 2017-09-28
  • 1970-01-01
  • 2019-10-14
  • 1970-01-01
  • 2021-12-10
  • 1970-01-01
相关资源
最近更新 更多