current position:Home>Vue monitors watch usage

Vue monitors watch usage

2022-04-29 07:25:55MFG_ six hundred and sixty-six

watch Monitoring must be monitor : Property value , That is to say data value

Case study

  data () {
    return {
      language: ''
    }
  },
  methods: {
    handleSetLanguage (lang) {
      this.$i18n.locale = lang;
      this.language = lang;
      localStorage.setItem("lang", lang);
    }
  },
  watch: {
    language: {
      handler (val) {
        console.log(val, ' Changed the ');
        if (val) {
          this.menuList = [{
            title: this.$t('navTop.aboutAllianceChain'),
            active: true,
          },
          {
            title: this.$t('navTop.metaUniverseMerchantAlliance'),
            active: false,
          },
          {
            title: this.$t('navTop.nftTradingPlatform'),
            active: false,
          },
          {
            title: this.$t('navTop.projectCommunity'),
            active: false,
          },
          {
            title: this.$t('navTop.newsAnnouncement'),
            active: false,
          },
          {
            title: this.$t('navTop.buyDag'),
            active: false,
          },
          {
            title: this.$t('navTop.purchaseGenesisNode'),
            active: false,
          },]
        }
      },
      immediate: true //  The representative enters the page and executes it first 
    }
  },

If you feel the article is good, remember to pay attention and collect , If there is something wrong, please correct it , If you need to reprint , Please indicate the source , Thank you very much !!!

copyright notice
author[MFG_ six hundred and sixty-six],Please bring the original link to reprint, thank you.
https://en.qdmana.com/2022/119/202204290458556028.html

Random recommended