<!-- 方法处理器 -->
<button v-on:click="doThis"></button>
<!-- 内联语句 -->
<button v-on:click="doThat('hello', $event)"></button>
<!-- 缩写 -->
<button @click="doThis"></button>
<!-- 停止冒泡 -->
<button @click.stop="doThis"></button>
<!-- 阻止默认行为 -->
<button @click.prevent="doThis"></button>
<!-- 阻止默认行为,没有表达式 -->
<form @submit.prevent></form>
<!-- 串联修饰符 -->
<button @click.stop.prevent="doThis"></button>
<!-- 键修饰符,键别名 -->
<input @keyup.enter="onEnter">
<!-- 键修饰符,键代码 -->
<input @keyup.13="onEnter">

应用实例html

<div id="content_area" class="aui-content aui-margin-b-15 mid">
<ul class="aui-list aui-list-in">
<li class="aui-list-header aui-text-center" style="background: #fff;padding: 1rem 0;">
<h1 class="color_organ aui-padded-b-10" style="font-size: 2rem;"><span v-cloak>{{DiamondAmount}}钻</span></h1>
<h3>账户余额</h3>
</li>
<li class="aui-list-item">
<div class="aui-list-item-inner">
<div class="aui-list-item-title"><img style="height:0.8rem;margin-left: 0.5rem;" src="../image/zb_zs.png">10
<!--<span class="color_organ aui-font-size-12">+7钻石(首充奖励)</span>-->
</div>
<div class="aui-list-item-right" v-on:click="buy('10');">
<div class="aui-label aui-label-danger aui-label-outlined">¥ 1</div>
</div>
</div>
</li>
<li class="aui-list-item">
<div class="aui-list-item-inner">
<div class="aui-list-item-title"><img style="height:0.8rem;margin-left: 0.5rem;" src="../image/zb_zs.png">60</div>
<div class="aui-list-item-right" v-on:click="buy('60');">
<div class="aui-label aui-label-danger aui-label-outlined">¥ 6</div>
</div>
</div>
</li>
<li class="aui-list-item">
<div class="aui-list-item-inner">
<div class="aui-list-item-title"><img style="height:0.8rem;margin-left: 0.5rem;" src="../image/zb_zs.png">300</div>
<div class="aui-list-item-right" v-on:click="buy('300');">
<div class="aui-label aui-label-danger aui-label-outlined">¥ 30</div>
</div>
</div>
</li>
<li class="aui-list-item">
<div class="aui-list-item-inner">
<div class="aui-list-item-title"><img style="height:0.8rem;margin-left: 0.5rem;" src="../image/zb_zs.png">980</div>
<div class="aui-list-item-right" v-on:click="buy('980');">
<div class="aui-label aui-label-danger aui-label-outlined">¥ 98</div>
</div>
</div>
</li>
</ul>
</div>

js

var vm = new Vue({
el: '#content_area',
data: data,
methods: {
buy : function (count) {
alert(count);
}
}
});

注意这里要用methods,不要忘记了s。

Vue绑定事件的更多相关文章

  1. 解决vue 绑定事件会覆盖默认参数的问题

    解决vue 绑定事件会覆盖默认参数的问题 在使用一些ui框架的时候,某些组件的框架中的事件所规定的参数不能满足实际开发的需要,但是直接传入参数会把默认的参数覆盖掉 解决方法:将参数放入箭头函数中,传递 ...

  2. Vue绑定事件,双向数据绑定,只是循环没那么简单

    v-on对象处理 <p @mouseover = "doTish" @mouseout = "doThat"> 对象形式 </p> &l ...

  3. vue的事件绑定

    vue事件有两方面内容:DOM事件 和 自定义事件. DOM事件 vue中采用DOM2级事件的处理方式,为IE9以上的浏览器服务.下面我们先来讲解一下什么是DOM2级事件吧! JS中DOM0级事件有两 ...

  4. vue for 绑定事件

    vue for 绑定事件 <div id="pro_list" v-for="item in pro_list"> <div class=&q ...

  5. [js高手之路] vue系列教程 - vue的事件绑定与方法(2)

    一.在vue中,绑定事件,用v-on:事件类型, 如绑定一个点击事件, 我们可以这样子做 window.onload = function () { var c = new Vue({ el : 'b ...

  6. Vue框架之双向绑定事件

    Vue框架之双向绑定事件 首先介绍下Vue框架的语法 vue通过 {{temp}} 来渲染变量 {{count+100}} # 求和 v-text # 为标签插入text文本 v-html # 为标签 ...

  7. vue form表单绑定事件与方法

    使用v-on绑定事件 <button @click="hello">Hello</button><br /> <button @click ...

  8. 第六十一篇:Vue的绑定事件和修饰符

    好家伙,补基础加实践 1.绑定事件 我们使用v-on(简写为@)来绑定事件 写个例子, 按钮绑定数字加一(太tm经典了) 在<button>元素中使用@点击事件绑定方法"的&qu ...

  9. vue中组件绑定事件时是否加.native

    组件绑定事件时 1. 普通组件绑定事件不能添加.native, 添加后事件失效 2. 自定义组件绑定事件需要添加.native, 否则事件无效 <template> <!-- < ...

随机推荐

  1. Oozie框架基础

    * Oozie框架基础 官方文档地址:http://oozie.apache.org/docs/4.0.0/DG_QuickStart.html 除Oozie之外,类似的框架还有: ** Zeus:h ...

  2. CUDA中的归约

    CUDA编程实战书中的乘方和解决办法: 对一个数组执行某种计算,然后产生一个更小的结果数组. 由一个线程在共享内存上进行迭代并计算出总和值.而如果用并行,所花时间就与数组长度的对数成正比. 代码的思想 ...

  3. SqlServer 删除日志

    1  数据库在使用过程中会使日志文件不断增加,使得数据库的性能下降,并且占用大量的磁盘空间.SQL Server数据库都有log文件,log文件记录用户对数据库修改的操作.可以通过直接删除log文件和 ...

  4. UI Framework-1: Aura Client API

    Client API The Aura Client API is an API Aura uses to communicate with the client application using ...

  5. UI Framework-1: Browser Window

    Browser Window The Chromium browser window is represented by several objects, some of which are incl ...

  6. error_reporting()函数

    定义和用法 error_reporting() 函数跪地你给应该报告何种 PHP 错误. error_reporting() 函数能够在运行时设置 error_reporting 指令. PHP 有诸 ...

  7. 运行npm start vue.js项目 出现 npm ERR! missing script: start 错误

    npm ERR! missing script: start 错误 有可能缺少依赖包,运行nmp install安装依赖(一般都依赖很多包,过程有点慢),安装完后发现多一个 node_modules文 ...

  8. BZOJ 3626 LCA(离线+树链剖分+差分)

    显然,暴力求解的复杂度是无法承受的. 考虑这样的一种暴力,我们把 z 到根上的点全部打标记,对于 l 到 r 之间的点,向上搜索到第一个有标记的点求出它的深度统计答案.观察到,深度其实就是上面有几个已 ...

  9. 三:redis的List类型相关操作

    </pre><pre name="code" class="php" style="font-size: 14px;"&g ...

  10. HDU 2444 The Accomodation of Students 二分图判定+最大匹配

    题目来源:HDU 2444 The Accomodation of Students 题意:n个人能否够分成2组 每组的人不能相互认识 就是二分图判定 能够分成2组 每组选一个2个人认识能够去一个双人 ...