1、方法调用

vue-引入js函数的方法和常量

a:  js文件(static/js/public.js)

//函数的定义  返回上一页
export function goback(laststep) { 
	 laststep
}

b: 调用

import {goback} from 'static/js/public.js'//记得带上{}花括号

methods:{
		_goback(){
			goback(this.$router.go(-1));
		}

	}

<span class="gobakc" @click="_goback"></span>

2、常量引用

a:文件 static/js/publicstate.js

const staticimg='../../../../static/images/';
export default
  {
  	staticimg, 

  }

b: import commonstate from 'static/js/publicstate.js'//引用模块进来

data(){
		return {
			imgsrc:commonstate.staticimg,
		}
	}

 <p>wrww{{imgsrc}}</p>

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-09-03
  • 2021-09-22
  • 2022-12-23
  • 2022-12-23
  • 2021-07-12
猜你喜欢
  • 2022-12-23
  • 2021-11-21
  • 2021-08-21
  • 2022-12-23
  • 2021-09-07
  • 2022-12-23
相关资源
相似解决方案