vue跨页面调用方法

阅读 74

2021-09-30

  1. 首页要创建一个js的文件;我将其命名为bug.js
import Vue from 'vue'
export default new Vue()
  1. 要操作使用的页面中,直接是
    引入bus文件:import bus from "@/utils/bus.js"
    使用方法:
 bus.$emit( 'updateKeyWords' , this.keywords);
  1. 接受的页面可以直接在mounted中接受
mounted(){
    let _this=this;
    bus.$on('updateKeyWords', function(val) {
      _this.keyWords=val
      _this.dialogVisible=true;
      _this.getverifyPic();
    })
  },

精彩评论(0)

0 0 举报