网创优客建站品牌官网
为成都网站建设公司企业提供高品质网站建设
热线:028-86922220
成都专业网站建设公司

定制建站费用3500元

符合中小企业对网站设计、功能常规化式的企业展示型网站建设

成都品牌网站建设

品牌网站建设费用6000元

本套餐主要针对企业品牌型网站、中高端设计、前端互动体验...

成都商城网站建设

商城网站建设费用8000元

商城网站建设因基本功能的需求不同费用上面也有很大的差别...

成都微信网站建设

手机微信网站建站3000元

手机微信网站开发、微信官网、微信商城网站...

建站知识

当前位置:首页 > 建站知识

Vue.js路由实现选项卡简单实例

本文实例为大家分享了Vue.js路由实现选项卡的具体代码,供大家参考,具体内容如下

创新互联建站主营阳西网站建设的网络公司,主营网站建设方案,app开发定制,阳西h5小程序制作搭建,阳西网站营销推广欢迎阳西等地区企业咨询

需要实现下图效果,点击上方选项卡,切换到不同内容的组件:

Vue.js路由实现选项卡简单实例

事先准备好两个库文件(vue.js、vue-router.js),放到对应路径。

1.引入依赖库



2.组件创建

const Html = Vue.extend({
      template: '

html

{{msg}}

', data: function() { return { msg: 'This is the html vue-router.' } } }); const Css = Vue.extend({ template: '

CSS

{{msg}}

', data(){ return{ msg: 'This is the CSS vue-router.' } } }); const Vue1 = Vue.extend({ template: '

Vue

{{msg}}

', data(){ return{ msg: 'This is the Vue vue-router.' } } }); const Javascript = Vue.extend({ template: '

Javascript

{{msg}}

', data(){ return{ msg: 'This is the Javascript vue-router.' } } });

3.路由创建与映射

const router = new VueRouter({
     routes: [
      { path: '/html', component: Html },
       { path: '/css', component: Css },
       { path: '/vue', component: Vue1 },
       { path: '/javascript', component: Javascript },
       { path: '/', component: Html } //默认路径
     ] 
    });

4.挂在实例

const vm = new Vue({
       router: router 
    }).$mount('#app');

5.页面,to指令跳转到指定路径

html css vue javascript

6.所用样式

 

完整代码




  
  hello world
  
  

 

  
html css vue javascript

如有错误之处,欢迎指出,万分感谢!

以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持创新互联。


分享文章:Vue.js路由实现选项卡简单实例
标题网址:http://bjjierui.cn/article/goeoss.html

其他资讯