我在我的单文件组件中被困在路由器中,我试图在单文件组件中包含另一个组件,例如我已经将thirdtemplate.vue命名为我的证监会,并且我使用Vue.component(“newTemplate”,{template:"…“)在其中包含另一个组件})正如我在这篇文章中向下展示的示例。我需要在我的newTemplate组件中使用路由器链接,以便它调用组件newTemplate的模板。
<template>
<div>
<h4>hello this is from thirdTemplate</h4>
<router-link to="/secondTemplate">Go to secondTemplate</router-link>
<router-link to="/thirdTemplate">Go to thirdTemplate</router-link>
<newtemplate></newtemplate>
</div>
</template>
<script>
Vue.component("newtemplate", {
template: "<template><div><button>hello</button></div></template>"
});
module.exports = {
name: "thirdTemplate",
methods: {},
components: {}
};
</script>
发布于 2019-10-17 19:05:07
将此代码移动到定义了新Vue构造函数的main.js
Vue.component("newtemplate", {
template: "<template><div><button>hello</button></div></template>"
});
并将路由器配置为第一个模板和第二个模板
https://stackoverflow.com/questions/58431001
复制相似问题