vue的点击事件,如何添加vue的click

news/2024/7/10 3:06:01 标签: vue, js

第一步
在html文件中填div元素,中间添加按钮信息

<html>
      
        <div>
            <input type="button" value="hamimelon!" />
        </div>

</html>

第二步
考虑关联点击事件

第一次思考:
添加

<html>
        <div>
            <input type="button" value="hamimelon!" />
        </div>
</html>
<script>
   
</script>

第二次思考:好像这样也不对

<html>
    <div>
        <input type="button" @click="display_alert" value="hamimelon!" />
    </div>
</html>
<script>
export default {
    data:{
        name:display_alert
        alert("完成vue的点击事件")
    }
}
</script>

http://www.niftyadmin.cn/n/957887.html

相关文章

springboot restTemplate https请求 忽略ssl证书

配置文件RestTemplateConfig import org.apache.http.conn.ssl.NoopHostnameVerifier; import org.apache.http.conn.ssl.SSLConnectionSocketFactory; import org.apache.http.impl.client.CloseableHttpClient; import org.apache.http.impl.client.HttpClientBuilder; impo…

SpringBoot配置Kafka的生产者与消费者

SpringBoot配置Kafka的生产者与消费者 1. 配置pom.xml 文件 <dependency> <groupId>org.springframework.kafka</groupId> <artifactId>spring-kafka</artifactId> </dependency> 2. 配置application.properties 文件 #zookeeper连…

终于写出了vue2的事件点击alert弹窗,下一步写vue3的

正确版本&#xff1a; <!DOCTPYE html> <html><head><title>ruguog</title></head> <body><div id"app"><input type"button" value"hamimelon!" click"test"/></div>&…

JSR303数据校验Bean Validation

后端校验技术 JSR303技术&#xff0c;JSR-303 是JAVA EE 6 中的一项子规范&#xff0c;叫做Bean Validation&#xff0c;Hibernate Validator 是 Bean Validation 的参考实现 . Hibernate Validator 提供了 JSR 303 规范中所有内置 constraint 的实现&#xff0c;除此之外还有…

vue3的事件处理代码

第一次的思考 引用的一定要改&#xff0c;从2.5的vue改为3以上的 <!DOCTPYE html> <html><head><title>ruguog</title></head> <body><div id"app"><input type"button" value"hamimelon!"…

event.target.tagName怎么用?没搞清楚,还是混沌的

如果是div&#xff0c;而不是input&#xff0c;则会变成DIV <!DOCTYPE html> <html><head><meta charset"UTF-8"><title></title><style type"text/css">#main {width: 200px;height: 100px;background: pink;…

过滤器(Filter)和拦截器(Interceptor)的区别

来自&#xff1a;http://www.cnblogs.com/luoyun/archive/2013/01/04/2844274.html 过滤器(Filter)和拦截器(Interceptor)的区别 Filter介绍 Filter可以认为是Servlet的一种“加强版”&#xff0c;它主要用于对用户请求进行预处理&#xff0c;也可以对HttpServletResponse进行…

不知道这段为什么有bug

const Person2 {name: little bear,sayHello: () > {SetTimeout(() > {console.log(我叫’this.name我今年this.age岁)}, 1000);} }; Person2.sayHello();