外部js调用vue实例方法

vue函数

mounted () {
window.testFun = this.testFun; // 方法赋值给window
},
methods: {
// vue内部方法
testFun () {

},
}

外部js调用

<script>

function test() {
testFun(); // 直接通过window方法去调用methods中对应方法
}

</script>

posted @ 2019-11-19 09:34  管的宽  阅读(4722)  评论(0编辑  收藏  举报