当前位置:网站首页>07_ Basic use of events
07_ Basic use of events
2022-07-19 01:37:00 【ID does not exist.】
The basic use of events
The basic use of events :
1. Use v-on:xxx or @xxx The binding event , among xxx Is the event name
2. Event callback needs to be configured in methods In the object , Eventually it will be vm On
3.methods Functions configured in , Don't use arrow functions , otherwise this It's not vm 了
4.methods Functions configured in , It's all about being vue Managed functions ,this The direction is vm Or component instance object
[email protected]="demo" and @click="demo($event)" The effect is consistent , But the latter can be passed on
<body>
<div id="root">
<h2> Welcome to {
{name}} Study </h2>
<!-- <button v-on:click="showInfo"> Click my prompt </button> -->
<button @click="showInfo1"> Click my prompt 1( Don't pass it on )</button>
<button @click="showInfo2($event,66)"> Click my prompt 2( The ginseng )</button>
</div>
</body>
<script type="text/javascript">
Vue.config.productionTip = false // prevent vue Generate production prompts at startup .
const vm = new Vue({
el: '#root',
data: {
name: ' Silicon Valley ',
},
methods: {
showInfo1(event) {
// console.log(event.target.innerText)
// console.log(this) // Here this yes vm
alert(' Hello, classmate !')
},
showInfo2(event, number) {
console.log(event, number)
// console.log(event.target.innerText)
// console.log(this) // Here this yes vm
alert(' Hello, classmate !!')
}
}
})
</script>边栏推荐
- Vue项目部署,清理缓存
- E-commerce background management login
- 服务器如何安装宝塔面板?(宝塔面板安装教程)
- Es optional chain
- iptables和snort基本配置
- 使用bat自动执行cmd命令(多个命令或单个命令)
- 今天的码农女孩学习了关于nodejs和REPL 交互式解释器的知识
- router和keep-alive
- The applet is embedded in the web page, jumps to the applet and transmits parameters. The wechat applet realizes the authorization of official account to obtain openid
- v-on的修饰符
猜你喜欢
随机推荐
Uni app wechat applet - Mall (6) - my home page
mock平台的使用说明
量化行业知识汇总
Win10 vscode 代码格式化设置与远程断点调试
深拷贝与浅拷贝
使用redis - zset做排行榜
红日靶场2
02_数据绑定
The applet is embedded in the web page, jumps to the applet and transmits parameters. The wechat applet realizes the authorization of official account to obtain openid
自己封裝的風格化的開關卡片組件
紅日安全靶場3
uni scroll-view 下拉刷新
TCP与UDP,TCP服务器与客户端,UDP服务器与客户端
“我的”Bug大全(转载)
Summary of XML external entity injection (xxE target recurrence)
数组操作——判断、去重、合并、展开
object-fit:cover;在小程序中不起作用,小程序图片变形了如何处理
Deployment of cobalstrike (with resources)
Uni app wechat official account (4) - address management page
JS intercepts the first few digits of the string or the last few digits of the string





![Stack injection [strong net cup 2019] random note](/img/94/9069ed79e994e3c2e96c3cd1f816ee.png)



