(21)打鸡儿教你Vue.js
组件化思想:
组件化实现功能模块的复用
高执行效率
开发单页面复杂应用
组件状态管理(vuex)
多组件的混合使用
vue-router
代码规范
vue-router
<template><div>hello info component</div>
</template><script>export default {name: "Info"}
</script><style scoped></style>
<template><div id="app"><div id="nav"><router-link to="/">Home</router-link> |<router-link to="/about">About</router-link> |<router-link to="/info">Info</router-link></div><router-view/></div>
</template>
export default new Router({routes: [{path: '/',name: 'home',component: Home},{path: '/info',name: 'info',component: Info},
Vuex
单向数据流概念
view actions state
Vuex多个视图依赖,菜单导航
不同视图的行为需要变更同一状态,评论弹幕
vue.js开发的状态管理模式
组件状态集中管理
import Vue from 'vue'
import Vuex from 'vuex'Vue.use(Vuex)export default new Vuex.Store({state: {},mutations: {},actions: {}
})
组件的状态
改变状态的方法集
<template><div>hello info component<button type="button" @click="add()">添加</button></div>
</template><script>
import store from '@/store'
export default {name: 'Info',store,methods: {add () {console.log('dashucoding')}}
}
</script><style scoped></style>
<template><div class="about"><h1>This is an about page</h1><p>{{msg}}</p></div>
</template>
<script>
import store from '@/store'
export default {name: 'about',store,data () {return {msg: store.state.count}}
}
</script>
<template><div>hello info component<button type="button" @click="add()">添加</button></div>
</template><script>
import store from '@/store'
export default {name: 'Info',store,methods: {add () {console.log('dashucoding')store.commit('increase')}}
}
</script><style scoped></style>
import Vue from 'vue'
import Vuex from 'vuex'Vue.use(Vuex)export default new Vuex.Store({state: {count: 0},mutations: {increase () {this.state.count++}},actions: {}
})
调式
<script>
import store from '@/store'
export default {name: 'Info',store,methods: {add () {console.log('add Event form info!')// alert('alert form info')debuggerstore.commit('increase')}}
}
<template><div>hello info component<button type="button" @click="add()">添加</button></div>
</template><script>
import store from '@/store'
export default {name: 'Info',store,data () {return {msg: 'hello vue'}},methods: {add () {console.log('dashucoding')debuggerstore.commit('increase')},output () {console.log('in output')}}
}
</script><style scoped></style>
console.logalert()debugger
window对象绑定
<template><div>hello info component<button type="button" @click="add()">添加</button></div>
</template><script>
import store from '@/store'
export default {name: 'Info',store,data () {return {msg: 'hello vue'}},mounted () {window.vue = this},methods: {add () {console.log('dashucoding')debuggerstore.commit('increase')},output () {console.log('in output')}}
}
</script><style scoped></style>
请点赞!因为你的鼓励是我写作的最大动力!
吹逼交流群:711613774
(21)打鸡儿教你Vue.js相关推荐
- (18)打鸡儿教你Vue.js
介绍一下怎么安装Vue.js vue.js Vue 不支持 IE8 及以下版本,因为 Vue 使用了 IE8 无法模拟的 ECMAScript 5 特性. Vue.js是一个渐进的,可逐步采用的Jav ...
- (17)打鸡儿教你Vue.js
vue-router <a class="list-group-item" v-link="{ path: '/home'}">Home</a ...
- (29)打鸡儿教你Vue.js
web阅读器开发 epub格式的解析原理 Vue.js+epub.js实现一个简单的阅读器 实现阅读器的基础功能 字号选择,背景颜色 有上一页,下一页的功能 设置字号,切换主题,进度按钮 电子书目录 ...
- (1)打鸡儿教你Vue.js
当今世界不会Vue.js,前端必定路难走 一个JavaScript MVVM库 以数据驱动和组件化的思想构建的 Vue.js是数据驱动 HTML/CSS/JavaScript/ES6/HTTP协议/V ...
- (26)打鸡儿教你Vue.js
weex框架的使用 1.weex开发入门 2.weex开发环境搭建 3.掌握部分weex组件模块 4.了解一些vue基本常见语法 5.制作一个接近原生应用体验的app weex介绍 安装开发环境 We ...
- (22)打鸡儿教你Vue.js
vue.js 单页面,多页面 Vue cli工具 复杂单页面应用Vue cli工具 交互设计,逻辑设计,接口设计 代码实现,线上测试 git clone,git int 创建分支,推送分支,合并分支 ...
- (19)打鸡儿教你Vue.js
了解vue2.x的核心技术 建立前端组件化的思想 常用的vue语法 vue-router,vuex,vue-cli 使用vue-cli工具 Vue框架常用知识点 vue核心技术 集成Vue 重点看,重 ...
- (15)打鸡儿教你Vue.js
组件化vue.js 组件单向绑定 组件双向绑定 组件单次绑定 创建组件构造器 注册组件 使用组件 Vue.extend() Vue.component() 使用组件 <div id=" ...
- (13)打鸡儿教你Vue.js
一小时复习 vue.js是一个JavaScriptmvvm库,是以数据驱动和组件化的思想构建的,相比angular.js,vue.js提供了更加简洁,更加容易理解的api,如果习惯了jquery操作d ...
最新文章
- 高速信号传输约翰逊 pdf_在PCB板边走高频高速信号线的注意事项
- iOS_Spring自动生成Model,Service,Controller 之 介绍
- unix命令的一般格式是_Linux tree 命令详细使用说明
- JAVA 正则表达式 分组
- MemoryMappingFile泄漏分析过程
- Zongsoft.Data 发布公告
- P4922-[MtOI2018]崩坏3?非酋之战!【dp】
- jsp人事管理系统_Jsp+Ssm+Mysql实现的医院人事管理系统源码附带视频运行教程
- 05_Grafana的安装和Influxdb数据源配置
- css Tab选项卡
- 组复制官方翻译六、Upgrading Group Replication
- Lvs+Keepalived高可用负载均衡配置
- 声音采集播放以及I2S接口
- 企业微信扫码登录流程
- C#实现PC与三菱PLC通讯
- 深度学习在搜狗无线搜索广告中的应用
- AUI 滚动视图使用
- 计算机网络---网络层
- 基于WT588F02B语音芯片的智能语音感应洗手液器设计方案
- 钢筋计数VOC数据集