Mixins and Vue.extend possible

This commit is contained in:
Sébastien Chopin 2016-11-18 14:45:25 +01:00
parent d4b8bc4f02
commit e48f8250a0
4 changed files with 18 additions and 6 deletions

View File

@ -14,8 +14,13 @@ function loadAsyncComponents (to, ___, next) {
return new Promise(function (resolve, reject) {
const _resolve = (Component) => {
// console.log('Component loaded', Component, match.path, key)
Component = Vue.extend(Component) // fix issue #6
Component._Ctor = Component
if (!Component.options) {
Component = Vue.extend(Component) // fix issue #6
Component._Ctor = Component
} else {
Component._Ctor = Component
Component.extendOptions = Component.options
}
match.components[key] = Component
resolve(Component)
}
@ -169,8 +174,13 @@ const resolveComponents = flatMapComponents(router.match(path), (Component, _, m
if (typeof Component === 'function' && !Component.options) {
return new Promise(function (resolve, reject) {
const _resolve = (Component) => {
Component = Vue.extend(Component) // fix issue #6
Component._Ctor = Component
if (!Component.options) {
Component = Vue.extend(Component) // fix issue #6
Component._Ctor = Component
} else {
Component._Ctor = Component
Component.extendOptions = Component.options
}
if (Component.options.data && typeof Component.options.data === 'function') {
Component._data = Component.options.data
if (NUXT.serverRendered) {

View File

@ -64,6 +64,9 @@ export default context => {
if (!Component.options) {
Component = Vue.extend(Component)
Component._Ctor = Component
} else {
Component._Ctor = Component
Component.extendOptions = Component.options
}
if (Component.options.data && typeof Component.options.data === 'function') {
Component._data = Component.options.data

View File

@ -69,7 +69,6 @@ module.exports = function () {
},
plugins: this.options.build.plugins
}
console.log(config.module.rules[1])
// Add nuxt build loaders (can be configured in nuxt.config.js)
config.module.rules = config.module.rules.concat(this.options.build.loaders)
// Return config

View File

@ -1,6 +1,6 @@
{
"name": "nuxt",
"version": "0.4.9",
"version": "0.5.0",
"description": "A minimalistic framework for server-rendered Vue.js applications (inspired by Next.js)",
"main": "index.js",
"license": "MIT",