vue公用函数和属性

commonjs

export default {
    
    
  fn1(vueObject){
    
    
	let that = vueObject
	//在方法中使用that是vue组件传过来的this,使用this是该公共类的就是对象,要使用该类中别的方法可以使用this.fn2()
	that.getDataNum = that.GLOBALjs.getDataNum
  },
  fn2(){
    
    },
  ...
}

vue

import commonFunction from '@/views/rue/js/common.js'
methods: {
    
    
        stopAudio(item){
    
    
            commonFunction.stopAudio(this,item)
         }
 }

猜你喜欢

转载自blog.csdn.net/weixin_46370288/article/details/141924988