成都创新互联网站制作重庆分公司

vue中命名视图的示例分析

这篇文章给大家分享的是有关vue中命名视图的示例分析的内容。小编觉得挺实用的,因此分享给大家做个参考,一起跟随小编过来看看吧。

创新互联公司IDC提供业务:绵阳电信机房机柜租用,成都服务器租用,绵阳电信机房机柜租用,重庆服务器租用等四川省内主机托管与主机租用业务;数据中心含:双线机房,BGP机房,电信机房,移动机房,联通机房。

vue中命名视图的示例分析

在views 创建 UserProfile.vue UserProfilePreview.vue文件

app.vue文件创建两个router-view :


两个router-link

Home |
profile|

在router.js

import Vue from 'vue'

import Router from 'vue-router'

import Home from './views/Home.vue'

import UserProfile from './views/UserProfile.vue'

import UserProfilePreview from './views/UserProfilePreview.vue'

Vue.use(Router)

export default new Router({

mode: 'history',

base: process.env.BASE_URL,

routes: [

{
 path: '/',
 name: 'home',
 component: Home
},
{
 path: '/profile',
 name: 'profile',
 components: {
  default: UserProfile,
  helper: UserProfilePreview
 }
}

]

})

当在浏览器窗口访问我们的命名视图时候

vue中命名视图的示例分析

vue中命名视图的示例分析

分别展示了对应的组件

总结:命名视图优点在于一个页面中相当于多个窗口,这些窗口我们可以根据

Home |
profile|的不同来展示不同的视图

感谢各位的阅读!关于“vue中命名视图的示例分析”这篇文章就分享到这里了,希望以上内容可以对大家有一定的帮助,让大家可以学到更多知识,如果觉得文章不错,可以把它分享出去让更多的人看到吧!


文章名称:vue中命名视图的示例分析
本文链接:http://cxhlcq.com/article/gcpcsg.html

其他资讯

在线咨询

微信咨询

电话咨询

028-86922220(工作日)

18980820575(7×24)

提交需求

返回顶部