是否可以更改Vue.js路由器视图名称?
我是Vue.js新手,我知道路由中有多个组件具有不同的名称 在App.vue文件中,是否可以将是否可以更改Vue.js路由器视图名称?,vue.js,vue-router,Vue.js,Vue Router,我是Vue.js新手,我知道路由中有多个组件具有不同的名称 在App.vue文件中,是否可以将更改为其他名称?谢谢你的帮助 HelloWorld.vue <template> <div class="hello"> <h1>{{ msg }}</h1> <h2>Essential Links</h2> </div> </template> <script> exp
更改为其他名称?谢谢你的帮助
HelloWorld.vue
<template>
<div class="hello">
<h1>{{ msg }}</h1>
<h2>Essential Links</h2>
</div>
</template>
<script>
export default {
name: 'HelloWorld',
data () {
return {
msg: 'Welcome to Your Vue.js App'
}
}
}
</script>
<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped>
h1, h2 {
font-weight: normal;
}
ul {
list-style-type: none;
padding: 0;
}
li {
display: inline-block;
margin: 0 10px;
}
a {
color: #42b983;
}
</style>
<template>
<div id="app">
<!-- <img src="./assets/logo.png"> -->
<router-view name="default"></router-view>
</div>
</template>
<script>
export default {
name: 'App'
}
</script>
<style>
#app {
font-family: 'Avenir', Helvetica, Arial, sans-serif;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
text-align: center;
color: #2c3e50;
margin-top: 60px;
}
</style>
你需要这个组件
Html代码
<template>
<div id="app">
<router-view :is="currentComponent"></router-view>
</div>
</template>
非常感谢。但如果我只是想静态地更改路由器视图名称。有什么建议吗?我希望可以,但路由器视图不支持更改名称标签
<template>
<div id="app">
<router-view :is="currentComponent"></router-view>
</div>
</template>
<script>
export default {
name: 'App' ,
components: {
LoginComponent,
HelloComponent
},
computed: {
currentComponent () {
return isTrue ? 'HelloComponent' : 'LoginComponent'
}
}
}
</script>