參考: https://www.cnblogs.com/zhcBlog/p/9892883.html
https://blog.csdn.net/xuerwang/article/details/82761214
https://www.cnblogs.com/liuyishi/p/9459289.htmlhtml
1、單個方法函數
var goBack = function() {
xxx
}
export default goBack;
import goBack from '../static/js/goBack';
Vue.prototype.$back = goBack; //用$與組件內自定義的函數區分,其餘符號也能夠
go: function() {
this.$back(); }
2、多個方法this
exports.install = function(Vue, options) { Vue.prototype.$back = function() { //全局函數1 xxx }; Vue.prototype.$pushH = function() { //全局函數2 xxx }; Vue.prototype.$pushHN = function() { //全局函數3 xxx }; };
import all from '../static/js/all'; Vue.use(all);//將全局函數當作插件來進行註冊
go: function() { this.$back(); }