computed watch 使用不了?
发布于 6 年前 作者 pshi 14352 次浏览 来自 问答

const moment = require("moment");
const {qxCloud } = require('../../../api/qxcloud');
const app = getApp();
const computedBehavior = require('miniprogram-computed');
Page({
  behaviors: [computedBehavior],
  /**
   * 页面的初始数据
   */
  data: {
    currentTab: "statistic",
    currnet:1,
    remedy:{
      rows:[],
      page:1,
      pageSize:10,
      total:0,
      loadEmpty:false,
      isLoading:false
    },
    errand:{
      rows:[],
      page:1,
      pageSize:10,
      total:0,
      loadEmpty:false,
      isLoading:false
    },
    vacations:{
      rows:[],
      page:1,
      pageSize:10,
      total:0,
      loadEmpty:false,
      isLoading:false

    },
  },
  watch: {
    'remedy.**'(remedy){
      console.log(remedy.rows);
      let self = this;
      if(self.data.currentTab == 'remedy' && self.data.batch_op.doing){
        console.log(remedy.rows);
      }
    },
    'vacations.**'(vacations){
      console.log(remedy.rows);
      let self = this;
      if(self.data.currentTab == 'vacation' && self.data.batch_op.doing){
        console.log(vacations.rows);
      }
    },
    'errand.**'(errand){
      console.log(remedy.rows);
      let self = this;
      if(self.data.currentTab == 'errand' && self.data.batch_op.doing){
        console.log(errand.rows);
      }
    },
  },
}
1 回复

构建npm了吗

回到顶部