界面是這樣的
源碼如下:
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中進行調用: