11、vue.js 之路由
来源:互联网 发布:投资网络电影赚钱吗 编辑:程序博客网 时间:2024/06/05 06:05
路由简单示例
<!DOCTYPE html><html lang="en"><head> <meta charset="UTF-8"> <title>Title</title> <meta name="keywords" content="hehe"/> <meta name="description" content="hehe"/> <script src="https://unpkg.com/vue/dist/vue.js"></script><!--引入vue.js--> <script src="js/vue-router.min.js"></script> <!--引入vue-router.js--></head><body> <div id="app"></div> <script> /*app模板 可看着整个页面的总模板 用来渲染路由*/ var App = Vue.component('app',{ template: `<div id="app"> <router-view></router-view> /*路由视图*/ </div>` }); /*home模板*/ var home = Vue.component('home',{ template: '<div><h1>{{content}}</h1></div>', data:function () { return {content:'这里是home'} } }); /*about模板*/ var about = Vue.component('about',{ template: '<div><h1>{{content}}</h1></div>', data:function () { return {content:'这里是about'} } }); /*路由*/ var router = new VueRouter({ routes:[ {path:'/home',component:home},/* /home 的时候渲染home模板 */ {path:'/about',component:about}/* /about 的时候渲染about模板 */ ] }); new Vue({ el: '#app', router,//路由 render: h => h(App)//render 页面默认的时候显示的是render指定模块的内容,此处代表默认显示App模块的内容 }) </script></body></html>运行效果:
阅读全文
1 0
- 11、vue.js 之路由
- 16、vue.js 之路由传值
- 18、vue.js 之路由钩子函数
- 15、vue.js 之路由与子路由
- Vue.js路由
- Vue.js两级路由
- 17、vue.js 之路由里的返回、前进、跳转
- vue框架之路由
- vue.js路由服务笔记
- 2.0vue.js 路由嵌套
- Vue.js框架路由练习
- 【21】vue.js — 路由
- Vue之动态路由、嵌套路由
- vue 进阶系列之路由
- vue学习总结之路由
- vue之登录路由验证
- vue之登录路由验证
- vue-router 之命名路由
- ubuntu16.04配置py-faster-rcnn(CPU版)
- 技术-Java连接mysql数据库
- 对于2-gram 条件下对英语文本的分词处理
- 【网易】双核处理
- T_FINISH
- 11、vue.js 之路由
- SparkSQL写数据到Hive的动态分区表
- Q&A——资源加载(一)
- Tecplot宏的循环结构
- javascript es6
- 0-1背包问题输出物品编号
- T_REP_FILE
- UVa 1395 kruscal变形
- @property 属性类型归纳和介绍