【发布时间】:2017-09-30 03:01:56
【问题描述】:
所以我已经安装了最新的 Vue CLI 并设置了一个项目。我熟悉 Vue 的概念,但我需要结构方面的帮助。有人可以指导我如何创建一个导航栏,该导航栏将在所有页面中使用并包含页面的 vue-router 链接?我的第一个想法是制作一个组件 Navbar.vue 并以某种方式将其放入 App.vue 以便在任何 <router-view></router-view> 之前呈现它。这是正确的方法吗?我会尝试把它放在 index.html 中吗?我对如何做到这一点感到困惑。我正在为 css 使用引导程序。
index.html:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>foo.ca</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta/css/bootstrap.min.css" integrity="sha384-/Y6pD6FV/Vv2HJnA6t+vslU6fwYXjCFtcEpHbNJ0lyAFsXTsjBbfaDjzALeQsN6M" crossorigin="anonymous">
</head>
<body>
<div id="app"></div>
<!-- built files will be auto injected -->
</body>
</html>
App.vue:
<template>
<div id="app">
<!--<img src="./assets/logo.png">-->
<router-view></router-view>
</div>
</template>
<script>
export default {
name: 'app'
}
</script>
【问题讨论】:
标签: vue.js