在开发我的应用程序时,我有一个包装器(本例简化),它是网站中所有元素的根 . 但是,我需要在此包装器旁边包含一个包含自定义属性的组件 . 就在那时我发现该组件上的属性从未被读入 .
index.html
TestItem.vue
{{ testProp }}
export default {
props: {
testProp: {
type: String,
default: "Default String"
}
}
}
Wrapper.vue
export default {
}
作为参考,我导入这些组件并初始化Vue实例:
Vue.component('test-item', require('./components/TestItem.vue'));
Vue.component('wrapper', require('./components/Wrapper.vue'));
const app = new Vue({
el: '#app'
});
我原本预料到,因为我在两个 **** 实例上传递 testProp ,输出看起来像
My Test Prop Outside Wrapper
My Test Prop Inside Wrapper
但是,这不是我所看到的,在包装器外面的一个,属性不通过,并使用默认属性值
Default String
My Test Prop Inside Wrapper
有什么想法发生了什么?