diff --git a/src/compiler/compile-props.js b/src/compiler/compile-props.js index ab5912b34db..74665be8178 100644 --- a/src/compiler/compile-props.js +++ b/src/compiler/compile-props.js @@ -38,6 +38,7 @@ const settablePathRE = /^[A-Za-z_$][\w$]*(\.[A-Za-z_$][\w$]*|\[[^\[\]]+\])*$/ export function compileProps (el, propOptions, vm) { var props = [] + var propsData = vm.$options.propsData var names = Object.keys(propOptions) var i = names.length var options, name, attr, value, path, parsed, prop @@ -122,6 +123,9 @@ export function compileProps (el, propOptions, vm) { } else if ((value = getAttr(el, attr)) !== null) { // has literal binding! prop.raw = value + } else if (propsData && ((value = propsData[name] || propsData[path]) !== null)) { + // has propsData + prop.raw = value } else if (process.env.NODE_ENV !== 'production') { // check possible camelCase prop usage var lowerCaseName = path.toLowerCase() diff --git a/test/unit/specs/directives/internal/prop_spec.js b/test/unit/specs/directives/internal/prop_spec.js index 95995f24589..084e2eeebf8 100644 --- a/test/unit/specs/directives/internal/prop_spec.js +++ b/test/unit/specs/directives/internal/prop_spec.js @@ -621,6 +621,36 @@ describe('prop', function () { expect(vm.a).toBe(123) }) + // # GitHub issues #3183 + it('pass propsData to create component that props is defined', function () { + var Comp = Vue.extend({ + template: '