【问题标题】:Route to another page using Vue使用 Vue 路由到另一个页面
【发布时间】:2019-04-13 01:08:06
【问题描述】:

我的模板中有以下代码:

<router-link to="/page1">Go to Page1</router-link>

Vue部分:

    const Page1 = { template: '<div>Hello Page1</div>' }

    const routes = [
        { path: '/page1', component: Page1 },
    ]

    const router = new VueRouter({
        routes
    })

    var app = new Vue({

        router,

        el: '#app',

    }).$mount('#app')

我希望 Page1 组件是一个类似于 page1.html 的 HTML 页面,而不是“Hello Page1”。我应该有

<router-view> </router-view>

在 page1.html 上?我该怎么做?

【问题讨论】:

    标签: vuejs2 vue-router


    【解决方案1】:

    我不太明白你的问题。您正在使用 Vue Router,它与 Vue 构建单页应用程序的方式集成。但是,您想显示一个普通的 html 页面吗?

    【讨论】:

    • 如何导入另一个页面作为组件与 Vue Router 一起使用?
    猜你喜欢
    • 1970-01-01
    • 2019-02-24
    • 1970-01-01
    • 1970-01-01
    • 2021-10-15
    • 1970-01-01
    • 2011-03-06
    • 1970-01-01
    • 2016-05-11
    相关资源
    最近更新 更多