博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
directives 自定义指令
阅读量:4320 次
发布时间:2019-06-06

本文共 858 字,大约阅读时间需要 2 分钟。

作用:间接操作dom 

属性参考:https://blog.csdn.net/hant1991/article/details/74626002

 

例子1:

  
directives:{ //间接操作dom color(el,bindings){ //你把指令放到谁身上,谁就是el el指的是button // console.log(arguments) // console.log(bindings) //bindings 绑定的属性,只是一个属性 el.style.background=bindings.value } }

 

例子2:

.box{  width: 100px;  height: 100px;  background: red;  position: absolute;}
directives:{ //间接操作dom drag(el){ el.onmousedown=function(e){ var disx=e.pageX-el.offsetLeft; var disy=e.pageY-el.offsetLeft; document.onmousemove=function (e){ el.style.left=e.pageX-disx+'px' el.style.top=e.pageY-disy+'px' } document.onmouseup=function(){ document.onmousemove=document.οnmοuseup=null } e.preventDefault() } } }

 

转载于:https://www.cnblogs.com/sayidf/p/10118561.html

你可能感兴趣的文章
基于Python的Webservice开发(二)-如何用Spyne开发Webservice
查看>>
PowerDesigner修改设计图中文字的字体大小等样式
查看>>
Python list和 np.Array 的转换关系
查看>>
jenkins忘记密码如何处理?
查看>>
布尔操作符-逻辑或(||)
查看>>
vim的列编辑操作
查看>>
Linux驱动学习 —— 在/sys下面创建目录示例
查看>>
Linux下安装Android的adb驱动-解决不能识别的问题
查看>>
Why is the size of an empty class not zero in C++?
查看>>
海亮SC
查看>>
[Hibernate] - Generic Dao
查看>>
【Linux】一步一步学Linux——Linux系统常用快捷键(12) 待更新...
查看>>
Vue中computed和watch使用场景和方法
查看>>
laravel路由与控制器(资源路由restful)
查看>>
Html5移动端页面自适应布局详解(阿里rem布局)
查看>>
memoize-one在React中的应用
查看>>
SpringBoot整合JDBC数据库操作第二弹-配置基本数据库连接源
查看>>
nginx日志切割脚本
查看>>
ipvsadm添加虚拟服务器报错问题
查看>>
LVS-DR集群搭建脚本
查看>>