【vue2】Style和Class,條件,列表渲染,雙向數據綁定,事件處理( 四 )


【vue2】Style和Class,條件,列表渲染,雙向數據綁定,事件處理

文章插圖
6.5 按鍵修飾符<!DOCTYPE html><html lang="en"><head><meta charset="UTF-8"><title>Title</title><script src="https://www.huyubaike.com/biancheng/js/vue.js"></script></head><body><div id="app"><input type="text" v-model="search" placeholder="請輸入搜索內容" @keyup.enter="handleUp"></div></body><script>var vm = new Vue({el: '#app',data:{search:''},methods:{handleUp(event){console.log('回車被按了')// if (event.code == 'Enter'){//console.log('回車間被按了',event)// }}}})</script></html>
【vue2】Style和Class,條件,列表渲染,雙向數據綁定,事件處理

文章插圖

推薦閱讀