Vue.js 学习总结
来源:互联网 发布:ubuntu 分区命令 编辑:程序博客网 时间:2024/05/20 07:51
Vue学习记录
数据绑定
v-model
:数据双向绑定
v-text
:数据展示
v-html
:数据含有html将会解析
v-bind
:绑定数据属性
注:v-bind 非常常用,Vue缩写 :xxx
v-on
:绑定事件
注:v-on 绑定的事件,可以在Vue内置方法methods中进行逻辑处理 缩写:@xxxx
逻辑控制
v-if
:接受一个boolean值来控制是否显示
v-show
:与v-if类似
v-if vs v-show : 区别就是v-show通过display属性来控制是否显示,v-if 通过boolean值来控制显示
v-for
: 循环条件
内置属性方法
data
:数据绑定的数据都要在data里面声明
methods
:v-on绑定的方法可以在这里面进行逻辑控制
compute
:能够把data声明的属性进行计算
Vue组件
- 声明一个组件
Vue.component('my-component',{template:'<p></p>'})
- 在html里面声明这个组件即可
<div id='app'> <my-component></my-component> </div>
- 在此模板中引入即可
子组件与父组件之间的通信
子组件向父组件通信(自定义事件)
通过$emit来向上传递事件
<my-component @send-to-parent='hello(param)'></my-component>
父组件:
methods:{ hello:function(param){ //todo } }
子组件:
somemethod:function(){ this.$emit('send-to-parent',param) }
父组件向子组件传递事件
通过props属性来接收这个参数
<my-component send-to-child='hello my son'></my-component>
子组件:
props:[ 'send-to-child' //这里指定之后就可以使用了 ]
路由(vue-router)
<div id='app'> //挂载在app下的组件,符合路由规则,则显示在router-view中 <router-view></router-view> </div>
路由配置:
//1.书写两个组件 const Foo = { template: '<div>foo</div>' } const Bar = { template: '<div>bar</div>' } //2. 路由表 const routes = [ { path: '/foo', component: Foo }, { path: '/bar', component: Bar } ] //3. 创建路由 const router = new VueRouter({ routes // (缩写)相当于 routes: routes }) //4. 挂在使用路由 const app = new Vue({ router }).$mount('#app')
动态路由
使用占位符来匹配路由表
const routes = [ //这里匹配 /foo/1 { path: '/foo/:id', component: Foo } ]
注:其中参数保存在this.$router.params.id
路由嵌套
上面路由配置例子:
//1.书写两个组件 const Foo = { template: ' //这里又嵌套了一个<router-view> <div id='foo'> <router-view></router-view> </div> ' } const Bar = { template: '<div>bar</div>' } //2. 路由表 const routes = [ //这里新增一个children 子组件将显示在foo下的<router-view>中 //地址匹配/foo/yourpath { path: '/foo', component: Foo,children:[ path:/yourpath, component:yourcomponent] }, { path: '/bar', component: Bar } ] //3. 创建路由 const router = new VueRouter({ routes // (缩写)相当于 routes: routes }) //4. 挂在使用路由 const app = new Vue({ router }).$mount('#app')
以上就是我学习Vue总结出来的常用方法函数指令
一个比较好的学习vue的例子 基于Vue的一个后台管理模板
vue官方文档 Vue官方文档
Element UI 饿了么组件库
Vue Meterial Vue Material风格组件
阅读全文
0 0
- vue.js总结学习
- Vue.js 学习总结
- Vue.js 学习要点总结(一)
- Vue.js 学习要点总结(二)
- 前端框架之Vue.js学习总结
- 新手学习vue.js 购物车实例 学习总结
- vue.js 总结
- vue.js总结
- Vue.js 实战总结
- Vue.js 实战总结
- vue.js使用总结
- Vue.js学习总结(1)——Windows下Vue.js开发环境搭建
- vue.js学习笔记(三)--父子组件通信总结
- Vue.js学习
- vue.js学习
- Vue.js学习
- Vue.js学习笔记
- Vue.js 学习笔记
- 关于二进制文件与文本文件
- Maven构建可分发Jar包
- Raft 算法原理及其在消息队列 CMQ 中的应用(上)
- [原创绿化] 批量文件改名工具【好压单文件版】
- 按钮
- Vue.js 学习总结
- Weblogic安装及配置(linux环境)
- mac 下vscode 部署go ethereum 过程 注意节点
- QML类与对象列表或分组
- 终端 学习Monkey的使用
- SpringMVC的异常处理
- java中继承类有参构造函数加载情况
- 小学生日记-excel:考勤表加班统计
- bootstrap 3.3.7dist下载地址