• 全局函数回调


    全局函数可以写一个文件globalFunc.js

    exports.install = function(Vue, option){
    Vue.prototype.setData = function(that, key){
    that[key] = '222'
    }

    Vue.prototype.testCallMe = function(str){
    console.log('test call me' + str)
    }

    Vue.prototype.testCallBack = function(func, param){
    func(param)
    this.testCallMe('tetetet')
    }
    }
    main.js

    import globalFunc from '@/components/globalFunc'

    Vue.use(globalFunc)

    vue文件中

    调用

    this.testCallBack(this.test, 'yui0')//使用全局函数调用vue文件中的函数,修改vue文件中的数据

    this.setData(this, 'msg')//使用全局函数修改vue文件中的数据

    test函数编写

    test:function(str){
    this.msg = '233' + str
    },

  • 相关阅读:
    xml转json
    3DES双倍长加密
    数据的集合运算
    SQL:1999基本语法
    表的连接操作
    数据库的连接
    表空间的创建
    用户的创建
    通用函数
    转换函数
  • 原文地址:https://www.cnblogs.com/dianzan/p/15480920.html
Copyright © 2020-2023  润新知