assets/js下我新建了一个global.js文件:
import Vue from "vue";import Router from "vue-router";export default({ //后退 back:function(){ this.$router.go(-1); }, })
main.js:
//全局方法import global from './assets/js/global.js'Vue.prototype.common = global
xx.vue:
<van-icon slot="right" @click="goto()">预览</van-icon> methods:{ //跳转 goto:function(){ this.common.back(); } }
我是不是哪里弄错了,全局方法不起作用?
PIPIONE
相关分类