【发布时间】:2019-05-16 05:28:13
【问题描述】:
我正在使用一个名为 Foo 的文件组件:
<template>
<div>
This is the app. X is {{ x }}, y is {{ y }}
</div>
</template>
<script>
export default {
data() {
return { x: 'hello x' };
},
}
</script>
我正在初始化我的应用程序:
// somewhere here 'node' gets set to a DOM node,
// and 'y' is created.
import Vue from 'vue';
import Foo from './Foo.vue';
const app = new Vue({
'el': node,
data: {y},
render: h => h(Foo)
});
这是一个过度简化,因为 'y' 实际上是一个对象,而不仅仅是一个简单的字符串。如果这有所作为。
我知道如何为 子组件 传递道具等,但我正在努力将主要配置数据导入顶级 Vue 应用程序!
【问题讨论】:
标签: javascript vue.js vuejs2