日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 前端技术 > vue >内容正文

vue

vue2中监听watch的写法汇总

發布時間:2023/12/16 vue 36 豆豆
生活随笔 收集整理的這篇文章主要介紹了 vue2中监听watch的写法汇总 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

vue2中監聽watch的寫法匯總

1

watch: {questionItem: {handler(val, oldVal) {if (val) {this.questionItem = JSON.parse(JSON.stringify(val))this.init()}},immediate: true, //刷新加載 立馬觸發一次handlerdeep: true // 可以深度檢測,里面每個值改變都會通知數據更新。},},
  • JSON.stringify()的作用是將 JavaScript 對象轉換為 JSON 字符串

  • JSON.parse()可以將JSON字符串轉為一個對象。

2

<template><el-dialog:title="activeLayerId == 'fdb_poi_merge' ? '新建POI點' : '新增點門牌'"width="400px"> </el-dialog> </template><script> export default {props: ['tableData', 'isFilter', 'datalist'],// 寫法二props: {dialogWidth: {type: String,default: '300px'}, },data(){return{form: {adoptedFlag: '', //情報反饋 },style: {position: 'top',width: this.dialogWidth,},activeLayerId: '', //當前圖層} },watch: {// 示例一'isFilter'(newVal) {if (newVal) {this.$refs.filterTable.clearSort(); // 清除排序this.$refs.filterTable.columnConfig.order = ''; // 清除排序高亮圖標this.$emit('updateData', !newVal);}},// 示例二 datalist(newV) {this.nameList = newV;this.query_conditions = [new Condition('', '', '', '=', '', '')];},// 示例三'$store.state.editTask.activePanel'() {const obj = {intelligenceDetails: '情報詳情',infoList: '情報列表',};this.$emit('updateTitle', obj[this.$store.state.editTask.activePanel]);},// 示例四'form.adoptedFlag': function (val) {this.showReason = val !== 1;if (val !== 1) {this.form.denyReason = '';}}, // 示例五dialogWidth(newValue) {this.data.style.width = newValue;},// 示例六'$store.state.map.activeLayerId'() {this.$nextTick(() => {this.activeLayerId = this.$store.state.map.activeLayerId;});},// 示例七'$store.state.map.hideLeft'() {this.displayLeft();},}, } </script>

總結

以上是生活随笔為你收集整理的vue2中监听watch的写法汇总的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。