Use watchers to keep an eye on your data. Watchers are methods that are invoked when the specified attribute changes. They are useful when you want to perform asynchronous operations in response to changing data.

<template>

    <section class="container">
<item-description></item-description>
<h1 class="title">
{{message | capitalize}}
</h1>
<button @click="changeMessage" class="button">Change Message</button>
<hr>
<section>
<h2>Mouse event</h2>
<div>{{counter}}</div>
<div @mouseover="inc">Mouse over here to change counter</div>
</section>
<section>
<h2>Keyboard events</h2>
<form @submit.prevent="submit">
<input type="text"
v-model="firstName"
@keyup.enter="submit"
@keyup.alt.ctrl.shift.down="keyeventHandler"/>
<button v-bind:disabled="buttonDisabled">{{buttonText}}</button>
</form>
<div>
{{key}}
</div>
</section>
</section>
</template> <style scoped>
.title
{
margin: 50px ;
} </style> <script> import ItemDescription from '../components/item-description'; export default {
data() {
return {
message: 'this is my vue!',
counter: ,
key: "",
firstName: "",
buttonText: "Add"
}
}, computed: {
buttonDisabled: function() {
return this.firstName == "";
}
},
watch: {
firstName: function(){
this.buttonText = this.firstName !== "" ? "Add " + this.firstName : "Add Dinosaur";
}
}, components: {
ItemDescription
}, filters: {
capitalize(value) {
return value.charAt().toUpperCase() + value.slice().toLowerCase();
}
}, methods: {
changeMessage() {
this.message = "Updated message here!"
}, inc() {
this.counter += ;
}, keyeventHandler() {
this.key = "Ctrl + alt + shift + down is clicked"
}, submit() {
console.log("form is submitted, the value is", this.firstName);
}
}
} </script>

最新文章

  1. Skype无法收发组消息
  2. linux mint 崩溃
  3. Debug与Release的区别
  4. CSS 属性 - 伪类和伪元素的区别
  5. ArcEngine开发:IElement.Geometry 值不在预期范围内 + 元素绘制代码
  6. 前端优化分析 之 javascript引用位置优化
  7. CSS之简单树形菜单
  8. twitter bootstrap 2.x 3.x区别
  9. POJ 2185 Milking Grid(KMP)
  10. wordpress换域名后无法登陆的解决方案
  11. Linux菜鸟之路[4]-cal,date,bc,echo $LANG,man
  12. leetcode第28题--Divide Two Integers
  13. ES 04 - 安装Kibana插件(6.6.0版本)
  14. 5、Flutter 实现 ViewPager、bottomNavigationBar 界面切换
  15. Rest概念学习
  16. 调试程序时如何用syslog来打印信息
  17. uniGUI 通过SessionList操作另外的登录用户
  18. koa 微信小程序 项目
  19. 书架 bookshelf
  20. Java中JDK,JRE和JVM之间的关系

热门文章

  1. ASM(四) 利用Method 组件动态注入方法逻辑
  2. “ping”命令的原理就是向对方主机发送UDP数据包,HTTP在每次请求结束后都会主动释放连接,因此HTTP连接是一种“短连接”
  3. Oracle调用Java类开发的存储过程、函数的方法
  4. JQuery的index()函数
  5. win10系统64位安装git后右键运行git bash here生成一个mintty.exe.stackdump文件后闪退解决方案
  6. [置顶] WebService学习总结(4)——第三方webService服务调用
  7. Jpa 的Persistence.xml配置讲解
  8. js进阶 13-7 如何实现滑动面板效果
  9. LeetCode Algorithm 04_Median of Two Sorted Arrays
  10. angular 响应式表单(登录实例)