首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >在单个文件组件中使用路由器链接

在单个文件组件中使用路由器链接
EN

Stack Overflow用户
提问于 2019-10-17 18:57:10
回答 1查看 55关注 0票数 1

我在我的单文件组件中被困在路由器中,我试图在单文件组件中包含另一个组件,例如我已经将thirdtemplate.vue命名为我的证监会,并且我使用Vue.component(“newTemplate”,{template:"…“)在其中包含另一个组件})正如我在这篇文章中向下展示的示例。我需要在我的newTemplate组件中使用路由器链接,以便它调用组件newTemplate的模板。

代码语言:javascript
运行
复制
<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>
EN

回答 1

Stack Overflow用户

发布于 2019-10-17 19:05:07

将此代码移动到定义了新Vue构造函数的main.js

代码语言:javascript
运行
复制
Vue.component("newtemplate", {
  template: "<template><div><button>hello</button></div></template>"
});

并将路由器配置为第一个模板和第二个模板

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/58431001

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档