Javascript代码:
var main = new Vue({
el: "#main",
data: {
currentView: "top",
},
});
var topComponent = Vue.component('top', Vue.extend({
template: "#top",
}));
现在,当我访问 main.currentView 时,我得到“顶部”。但是有了这个字符串’top’,我如何获得组件 topComponent
?
原文由 Preethi 发布,翻译遵循 CC BY-SA 4.0 许可协议
来自 VueJS 指南