当前位置:网站首页>07_事件的基本使用
07_事件的基本使用
2022-07-17 00:06:00 【id不存在。】
事件的基本使用
事件的基本使用:
1.使用v-on:xxx或@xxx绑定事件,其中xxx是事件名
2.事件的回调需要配置在methods对象中,最终会在vm上
3.methods中配置的函数,不要用箭头函数,否则this就不是vm了
4.methods中配置的函数,都是被vue所管理的函数,this的指向是vm或组件实例对象
[email protected]="demo"和@click="demo($event)"效果一致,但后者可以传参
<body>
<div id="root">
<h2>欢迎来到{
{name}}学习</h2>
<!-- <button v-on:click="showInfo">点我提示信息</button> -->
<button @click="showInfo1">点我提示信息1(不传参)</button>
<button @click="showInfo2($event,66)">点我提示信息2(传参)</button>
</div>
</body>
<script type="text/javascript">
Vue.config.productionTip = false //阻止 vue 在启动时生成生产提示。
const vm = new Vue({
el: '#root',
data: {
name: '尚硅谷',
},
methods: {
showInfo1(event) {
// console.log(event.target.innerText)
// console.log(this) //此处的this是vm
alert('同学你好!')
},
showInfo2(event, number) {
console.log(event, number)
// console.log(event.target.innerText)
// console.log(this) //此处的this是vm
alert('同学你好!!')
}
}
})
</script>边栏推荐
- uni-app微信小程序——商城(8)——订单详情
- uni-app微信公众号(4)——地址管理页面
- TCP与UDP,TCP服务器与客户端,UDP服务器与客户端
- uni-app微信小程序——商城(3)——商城主页
- The C Programming Language (2nd)--笔记--1.6
- The C Programming Language (2nd)--笔记--1.8
- 2022年暑假ACM热身练习1(总结)
- The C Programming Language 2nd --笔记--6.7
- everything搜索不到startup_lpc11x.s文件
- Summary of XML external entity injection (xxE target recurrence)
猜你喜欢

分布式之数据库和缓存双写一致性方案解析(转载)

Quine injection of SQL injection
![Buuctf [bjdctf2020]ezphp1 detailed explanation](/img/10/d2593dff2f4a5f0ca41a9f651128df.png)
Buuctf [bjdctf2020]ezphp1 detailed explanation

Day06 ORM field and operation

uni-app微信小程序——商城(4)——商家

The C Programming Language (2nd)--笔记--1.6

【ElenmentUI el-date-picker日期选择器,结束时间不得早于开始时间,且只能选择距开始时间指定天数的日期】

JS intercepts the first few digits of the string or the last few digits of the string

自己封裝的風格化的開關卡片組件

MoveIt2——4.机器人模型和机器人状态
随机推荐
使用leaflet仿原神提瓦特大地图制作日记
C Programming Language (2nd Edition)--读书笔记--1.3
uni 阻止按钮多次点击 按钮多次点击
MoveIt2——2.MoveIt在RViz中的快速入门
v-on的修饰符
Uni app wechat applet - Mall (7) - Product Details
gtest与gmock的安装与使用
[elementui El date picker date selector, the end time must not be earlier than the start time, and only the date of the specified number of days from the start time can be selected]
今天的码农女孩学习了关于事件操作和ref属性的笔记并做了表单双向绑定的练习
数据库连接池、sequelize实现增删改查等操作
uni-app微信小程序——商城(4)——商家
Deployment of cobalstrike (with resources)
微信推送-模版消息参数配置
(10)文件包含
promise
判断两个时间戳是否是同一天
使用bat自动执行cmd命令(多个命令或单个命令)
Day12 Association serialization processing
everything搜索不到startup_lpc11x.s文件
The C Programing Language-2nd--笔记--4.11.3