1 Star 0 Fork 0

simple-lui/vue210127

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
21-v-on的基本使用.html 1.13 KB
一键复制 编辑 原始数据 按行查看 历史
simple-lui 提交于 2021-02-25 23:33 +08:00 . innit commit
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body>
<div id="app">
<h2>{{message}}</h2>
<h2>{{counter}}</h2>
<!-- <button v-on:click="counter++">+</button>-->
<!-- <button v-on:click="counter&#45;&#45;">-</button>-->
<!-- <button v-on:click="increment()">+</button>-->
<!-- <button v-on:click="decrement()">-</button>-->
<button @click="increment()">+</button>
<button @click="decrement()">-</button>
<!-- 什么情况下方法后面需要加上括号???-->
<!-- {{code}}显示"function () { [native code]}"-->
<button @click="decrement">{{code()}}</button>
</div>
<script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
<script>
const app = new Vue({
el: '#app',
data: {
message: 'simplelu',
counter: 0
},
methods: {
increment() {
this.counter++;
},
decrement() {
this.counter--;
},
code() {
return '--'
}
}
})
</script>
</body>
</html>
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/simplelu/vue210127.git
git@gitee.com:simplelu/vue210127.git
simplelu
vue210127
vue210127
master

搜索帮助