Web前端笔记-浏览器控制台调用js函数及vue函数

界面是这样的

源码如下:

index.html

<html>
<head>
</head>

<body>
<h1>Hello World</h1>
<script type="text/javascript" src="js.js"></script>

<script type="text/javascript">

	function callFunctionDemo(){

		alert("Hello World");
	}
	
</script>

</body>

</html>

js.js

;

function jsFileCall(){
	
	
	alert("jsFileCall");
}

在控制台中调用

jsFileCall()

通过这种方式就可以进行弹窗了。

下面是vue中,首先在指定的vue文件中

export default {

  name: 'HelloWorld',
  data () {
    return {
    }
  },
  mounted() {
    window.mainPage = this;
    this.init();
  },
  methods:{

    callVueFunction(){

      alert("callVueFunction");
    },
   ....
   ....
   ....
}

这样的话在vue中进行调用:

 

猜你喜欢

转载自blog.csdn.net/qq78442761/article/details/106859560
今日推荐