最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Error Vue.js "Cannot read property 'props' of undefined" - Stack Overflow

programmeradmin2浏览0评论

Did everything on gorails tutorial, but something wrong. error message in Chrome:

Uncaught TypeError: Cannot read property 'props' of undefined   
    at normalizeProps (vue.runtime.esm.js?ff9b:1291)   
    at mergeOptions (vue.runtime.esm.js?ff9b:1363)   
    at mergeOptions (vue.runtime.esm.js?ff9b:1372)   
    at Vue$3.Vue._init (vue.runtime.esm.js?ff9b:4268)   
    at new Vue$3 (vue.runtime.esm.js?ff9b:4384)  
    at HTMLDocument.eval (hello_vue.js?94ab:29)     
    at Object.t.dispatch (turbolinks.self-)   
    at r.t.Controller.r.notifyApplicationAfterPageLoad ...)   
    at r.t.Controller.r.pageLoaded (t...)   
    at turbolinks.self...  

Hello_vue file:

import Vue from 'vue'
import TurbolinksAdapter from "vue-turbolinks"
import VueResource from "vue-resource"

Vue.use(VueResource);

document.addEventListener('turbolinks:load', () => {

    Vue.http.headersmon["X-CSRF-Token"] = document.querySelector('meta[name="csrf-token"]').getAttribute("content");

  var element = document.getElementById("team-form")

  if(element != null){

    var team = JSON.parse(element.dataset.team);
    var players_attributes = JSON.parse(element.dataset.playersAttributes);
    players_attributes.forEach(function(player){
        player._destroy = null  
    })
    team.players_attributes = players_attributes;

    var app = new Vue({
        el: element,
        mixins: [TurbolinksAdapter],
        data: function(){
            return { team: team }
        },
        methods: {
            addPlayer: function(){
                team.players_attributes.push({
                id: null,
                name: "",
                _destroy: null
                })
            }
        }
    });
  }
});

as I understand, an error in the initialization of the App object, but I can not understand in what exactly. I kind of did it right.

Did everything on gorails tutorial, but something wrong. error message in Chrome:

Uncaught TypeError: Cannot read property 'props' of undefined   
    at normalizeProps (vue.runtime.esm.js?ff9b:1291)   
    at mergeOptions (vue.runtime.esm.js?ff9b:1363)   
    at mergeOptions (vue.runtime.esm.js?ff9b:1372)   
    at Vue$3.Vue._init (vue.runtime.esm.js?ff9b:4268)   
    at new Vue$3 (vue.runtime.esm.js?ff9b:4384)  
    at HTMLDocument.eval (hello_vue.js?94ab:29)     
    at Object.t.dispatch (turbolinks.self-)   
    at r.t.Controller.r.notifyApplicationAfterPageLoad ...)   
    at r.t.Controller.r.pageLoaded (t...)   
    at turbolinks.self...  

Hello_vue file:

import Vue from 'vue'
import TurbolinksAdapter from "vue-turbolinks"
import VueResource from "vue-resource"

Vue.use(VueResource);

document.addEventListener('turbolinks:load', () => {

    Vue.http.headers.common["X-CSRF-Token"] = document.querySelector('meta[name="csrf-token"]').getAttribute("content");

  var element = document.getElementById("team-form")

  if(element != null){

    var team = JSON.parse(element.dataset.team);
    var players_attributes = JSON.parse(element.dataset.playersAttributes);
    players_attributes.forEach(function(player){
        player._destroy = null  
    })
    team.players_attributes = players_attributes;

    var app = new Vue({
        el: element,
        mixins: [TurbolinksAdapter],
        data: function(){
            return { team: team }
        },
        methods: {
            addPlayer: function(){
                team.players_attributes.push({
                id: null,
                name: "",
                _destroy: null
                })
            }
        }
    });
  }
});

as I understand, an error in the initialization of the App object, but I can not understand in what exactly. I kind of did it right.

Share Improve this question asked Sep 15, 2017 at 11:58 mr.Zaurmr.Zaur 3711 gold badge2 silver badges7 bronze badges 1
  • I am getting this as well, it is happening when I use object3D as a mixin from vue-threejs. When I walk through it. It fails because the mixin is a function and doesn't have any options property. I think this is probably a bug in the vue framework. – Matt Fenner Commented Jun 30, 2019 at 11:08
Add a comment  | 

3 Answers 3

Reset to default 20

error in mixins: [TurbolinksAdapter]

removed that line and added Vue.use(TurbolinksAdapter); after Vue.use(VueResource); and it all worked

I've got this issue by misspelling a variable in the Vue mixins array. for example:

import file from '../folder/with/file'
export default: {
    mixins: [
        fil
    ]
}

should be

import file from '../folder/with/file'
export default: {
    mixins: [
        file
    ]
}

Probably late to the party and since this was the second answer google showed, thought this would help someone!

If anyone faced this because of provide/inject, I might probably have to do with vue2 / vue3. I read articles on provide/inject in vue3 and used it in my vue2 project

发布评论

评论列表(0)

  1. 暂无评论