简体   繁体   English

“无法读取未定义事件的属性”Vue.JS

[英]'Cannot read properties of undefined events' Vue.JS

  <FullCalendar id="calendar"
  :options="calendarOptions"
  />
</section>

export default {
  components: {
    FullCalendar
  },
  
  
  data() {
    return {
      calendarOptions: {
        plugins: [dayGridPlugin ,interactionPlugin, timeGridPlugin, listPlugin],

  methods:{
    newEvent(){
      var theCalendar = document.getElementById("calendar");
      var eventName = document.getElementById("Ename").value;
      var sDate = document.getElementById("startDate").value;
      var eDate = document.getElementById("endDate").value;
      var type = document.getElementById("bookingType").value;
      var number = document.getElementById("numberOfPeople").value;
      
      //The addEvent can't be accessed, currently this function doesn't have access to the object Fullcalendar and because of that
      //we can't use addEvent.
        theCalendar.addEvent({
        title: eventName,
        start: sDate,
        allDay: true
      });
      alert('Great. Now, update your database...');

    }
  }

Hello, my vue.JS code at the moment cant read undefined properties.您好,我的 vue.JS 代码目前无法读取未定义的属性。 I want to be able to populate the addEvent class with my calendar properties.我希望能够使用我的日历属性填充 addEvent 类。

if you are trying to access the API如果您尝试访问 API

you should provide a ref on your calendar你应该在你的日历上提供一个参考

<FullCalendar ref="fullCalendar" :options="calendarOptions" />

which can then be accessed as so然后可以这样访问

let calendarApi = this.$refs.fullCalendar.getApi()
calendarApi.next()

see here这里

however i suspect that you actually want is to access the calendarOptions object which is as simple as但是我怀疑您实际上想要的是访问 calendarOptions 对象,它很简单

this.calendarOptions.events

assuming you have defined the object as specified on the previous link假设您已按照上一个链接中的指定定义对象

data() {
  return {
    calendarOptions: {
      plugins: [ dayGridPlugin, interactionPlugin ],
      events: [
        { title: 'event 1', date: '2019-04-01' },
        { title: 'event 2', date: '2019-04-02' }
      ]
    }
  }
},

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Vue.js:“TypeError:无法读取未定义的属性(读取'$refs)'” - Vue.js: "TypeError: Cannot read properties of undefined (reading '$refs)'" Vue.js 错误:TypeError:无法读取未定义的属性 - Vue.js error: TypeError: Cannot read properties of undefined 无法读取vue.js中“未定义”的属性 - Cannot read property of 'Undefined' in vue.js Vue.JS - Api 请求 - 未捕获(承诺中)TypeError:无法读取未定义的属性(读取“报价”) - Vue.JS - Api request - Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'quote') vue.js中的&#39;无法读取未定义的属性&#39;color1&#39;&#39;错误 - 'Cannot read property 'color1' of undefined' error in vue.js “类型错误:无法读取未定义的属性‘服务’”Vue.js + Vuefire - "TypeError: Cannot read property 'servicios' of undefined" Vue.js + Vuefire TypeError:无法读取未定义的属性“标题”。 Vue.js - TypeError: Cannot read property 'title' of undefined. Vue.js 无法使用 vue.js 和 axios 读取未定义的属性“帖子” - Cannot read property 'post' of undefined using vue.js and axios Vue.js 无法读取未定义的属性“集合” - Vue.js Cannot read property 'collection' of undefined Vue.js + Firestore 无法读取未定义的属性“集合” - Vue.js + Firestore Cannot read property 'collection' of undefined
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM