alexjoverm / v-runtime-template

Vue component for compiling templates on the fly using a v-html like API
MIT License
605 stars 70 forks source link

this.$options is undefined #26

Closed christiancannata closed 5 years ago

christiancannata commented 5 years ago

Hi, I have followed the instructions but It doesn't work! This is the error: "TypeError: this.$options is undefined" found in ---> VRuntimeTemplate

This is the code: template component

phoenixdev-kl commented 5 years ago

I have basically the same issue, even though the error message is a different one:

TypeError: Cannot read property 'validations' of undefined
     at Object.data (/var/www/node_modules/vuelidate/lib/index.js:508:30)
     at Object.mergedDataFn [as data] (/var/www/node_modules/vue/dist/vue.runtime.common.js:1167:53)
     at getKeysFromOptions (node_modules/v-runtime-template/dist/v-runtime-template.es.js:7:45)
     at Proxy.render (node_modules/v-runtime-template/dist/v-runtime-template.es.js:45:0)
     at VueComponent.Vue._render (/var/www/node_modules/vue/dist/vue.runtime.common.js:4542:22)
     ... and so on ...

Was able to track it down to $options being undefined in vuelidate module:

const vals = this.$options.validations

(see vuelidate's index.js on GitHub)

No solution yet, will see what I can find out ... but merged data functions logic in vue.js looks hot:

    // when parentVal & childVal are both present,
    // we need to return a function that returns the
    // merged result of both functions... no need to
    // check if parentVal is a function here because
    // it has to be a function to pass previous merges.
    return function mergedDataFn () {
      return mergeData(
        typeof childVal === 'function' ? childVal.call(this, this) : childVal,
        typeof parentVal === 'function' ? parentVal.call(this, this) : parentVal
      )
    }

(see vue.js' vue.runtime.common.js on GitHub)

Oh, I see, there's already an issue for the vuelidate conflict: #15

@christiancannata But chances are that Solinx' quick fix could solve your problem too.

alexjoverm commented 5 years ago

Yep, let's better track it on #15