Vue组件编写
2024-09-03 03:33:01
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无效。
最新文章
- Linux 任务控制
- 可拖动的DIV续
- Hybrid框架UI重构之路:四、分而治之
- C#打开摄像头抓取照片然后退出
- mongodb 3.0 版本分片部署步骤
- shell编程之sleep的运用
- 生成24位字符串ID__IdGenerator.java
- Dubbo认识
- 二十、mysql mysqldump备份工具
- 一步一步学android控件(之十五) —— DegitalClock &; AnalogClock
- 课程助理For Windows(预览版,正方教务系统学生查分工具)
- MySQL两阶段提交
- SqlBulkCopy 参数配置示例
- SpringBoot学习笔记(一)入门
- zabbix监控实战<;1>;
- 2016word多级列表 一级标题居中后偏左
- eval() 和 with()
- 网站程序CMS识别
- MT【173】齐次消元单变量
- (笔记)Linux常用命令大全