Vue无疑是近来最火的一个前端框架,它吸取了angular1.x和react的精华,性能优良,而且易于上手,本文主要是关于如何去写一个组件。

首先是项目目录

编写组件

在这里我写了一个日期控件(移动端的),在components目录下建立文件夹,并建立vue文件和index.js文件注册组件。

.vue文件中的内容我就不多说了,去看我的项目即可。

组件注册

import datepicker from './datepicker.vue'
//这里第一个参数可以设置别的名字,作为页面标签使用
datepicker.install = (Vue) => Vue.component('datepicker',datepicker)
export default datepicker

组件使用

import datepicker from './components/datepicker'
import Vue from 'vue'
Vue.use(datepicker);
//html中
<datepicker @cancle="cancle" @sure="sure" :selecteddate="olddate"></datepicker>

最后附上代码地址https://github.com/Stevenzwzhai/vue-datepicker

演示地址 https://stevenzwzhai.github.io/vue-datepicker/。打开mobile调试模式,因为使用了touch事件,所以pc无效。

最新文章

  1. Linux 任务控制
  2. 可拖动的DIV续
  3. Hybrid框架UI重构之路:四、分而治之
  4. C#打开摄像头抓取照片然后退出
  5. mongodb 3.0 版本分片部署步骤
  6. shell编程之sleep的运用
  7. 生成24位字符串ID__IdGenerator.java
  8. Dubbo认识
  9. 二十、mysql mysqldump备份工具
  10. 一步一步学android控件(之十五) —— DegitalClock &amp; AnalogClock
  11. 课程助理For Windows(预览版,正方教务系统学生查分工具)
  12. MySQL两阶段提交
  13. SqlBulkCopy 参数配置示例
  14. SpringBoot学习笔记(一)入门
  15. zabbix监控实战&lt;1&gt;
  16. 2016word多级列表 一级标题居中后偏左
  17. eval() 和 with()
  18. 网站程序CMS识别
  19. MT【173】齐次消元单变量
  20. (笔记)Linux常用命令大全

热门文章

  1. GL格式一览表
  2. 如何把某个网站的SSL Server certificate链导入到ABAP Netweaver系统里
  3. POJ-2376 Cleaning Shifts---区间覆盖&amp;贪心
  4. 进程、内存的理想与现实 VS 虚拟内存
  5. Windows Thin PC(7月2日发布)下载+激活+汉化
  6. python模块之正则
  7. Git工作流指南:功能分支工作流(转)
  8. C#如何使用异步编程【BeginInvoke/EndInvoke】
  9. Oracle中文乱码解决
  10. Mybatis与Hibernate区别