<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
</head>
<body>
<script src="https://unpkg.com/vue@2.5.16/dist/vue.js"></script>
<div id="app">
<input type="text" v-model="available_time" v-format-floor>
<input type="text" v-model="a" v-format-floor>
<button @click="show">button</button>
</div>
<script>
var vm = new Vue({
el:"#app",
data:{
available_time:"",
a: '',
},
methods:{
show(){
console.log(this.a)
}
},
directives: { "format-floor": {
update: function (e,vnode,oldVnode) {
// 获取变量名字
var temp = oldVnode.data.directives[0].expression;var e = e.value;
e = Math.floor(e) || 0;
vm[temp] = e;
}
}
}
})
</script>
</body>
</html>

自定义指令 格式化input数据为非负整数的更多相关文章

  1. AngularJS: 自定义指令与控制器数据交互

    <!doctype html> <html> <head> <meta charset="utf-8"> <title> ...

  2. angular5 自定义指令 输入输出 @Input @Output(右键点击事件传递)

    指令写法,angular5官网文档给的很详细. 首先要创建一个文件,需注意命名规范(后缀名为xxx.directive.ts): 今天要记录的是在多个li中,右键点击之后显示出对应的菜单,直接上图吧! ...

  3. PHP自定义函数格式化json数据怎么调用?

    <?php/*** Formats a JSON string for pretty printing** @param string $json The JSON to make pretty ...

  4. 自定义指令 限制input 的输入位数

    <!DOCTYPE html> <html lang="en"> <head>     <meta charset="UTF-8 ...

  5. Vue自定义指令实现input限制输入正整数

    directive.js import Vue from 'vue' export default () => { Vue.directive('Int', { inserted: functi ...

  6. Vue自定义指令 数据传递

    在项目开发过程中,难免会遇到各种功能需要使用Vue自定义指令--directive 去实现 .关于directive的使用方式这里就不做过多的介绍了,Vue官方文档中说的还是听明白的.今天讲讲在使用V ...

  7. vue自定义指令v-scroll(directive)

    vue开发中,很多地方如果说都用到了某一方法,我们就可以进行指令化封装,通过自定义指令来实现这里通过两个例子说明vue-Directive的使用 1.v-focus 主要用来实现页面加载进来的时候文本 ...

  8. vue3.0自定义指令(drectives)

    在大多数情况下,你都可以操作数据来修改视图,或者反之.但是还是避免不了偶尔要操作原生 DOM,这时候,你就能用到自定义指令. 举个例子,你想让页面的文本框自动聚焦,在没有学习自定义指令的时候,我们可能 ...

  9. VUE3 之 自定义指令的实现 - 这个系列的教程通俗易懂,适合新手

    1. 概述 老话说的好:能屈能伸的人生,才是完满而丰富的人生. 言归正传,今天我们来聊聊 VUE 中自定义指令的实现. 2. 自定义指令 2.1 文本框聚焦的实现  <body> < ...

随机推荐

  1. java-源文件中可以有多个类,但是最多只能有一个public修饰

    1.如果源文件中有多个类,那么只能有一个类是public类:如果有一个类是public类,那么源文件的名字必须与这个类的名字完全相同,扩展名是.java. 2.如果源文件中没有public类,那么源文 ...

  2. 2017.4.4 TCP/IP三次握手,四次挥手

    之前在电话面试的时候,被问到,所以找到一个超级容易理解的图片,自己保存,也算分享.

  3. 【HDOJ3018】【一笔画问题】【欧拉回路+并查集】

    http://acm.hdu.edu.cn/showproblem.php?pid=3018 Ant Trip Time Limit: 2000/1000 MS (Java/Others)    Me ...

  4. 杜教BM

    #include <algorithm> #include <iterator> #include <iostream> #include <cstring& ...

  5. java exception 01

    问题:java.util.concurrentmodificationexception 背景:java thread 网上找到的出现的例子如下(项目中真实的code不便给出) public clas ...

  6. Tomcat建立多个应用(Web Server),多个主机,多个站点的方法

    https://blog.csdn.net/chungle2011/article/details/52317433 http://piperzero.iteye.com/blog/1475773 转 ...

  7. Linux配置浮动IP

    在高可用集群环境中,一般都需要使用浮动IP来实现web高可用(High Availability). 浮动IP的概念以及为什么需要浮动IP请参考:https://blog.csdn.net/readi ...

  8. Module Sources

    转自:https://www.terraform.io/docs/modules/sources.html 主要记录module source 的格式 The source argument in a ...

  9. How to implement long running flows, sagas, business processes or similar

    转自:https://blog.bernd-ruecker.com/how-to-implement-long-running-flows-sagas-business-processes-or-si ...

  10. 2D Platformer 学习

    using UnityEngine; using System.Collections; /// <summary> /// 玩家控制 /// </summary> publi ...