vue 函数
- mounted () {
- Windows.testFun = this.testFun; // 方法赋值给 Windows
- },
- methods: {
- // vue 内部方法
- testFun () {
- },
- }
外部 JS 调用
- <script>
- function test() {
- testFun(); // 直接通过 Windows 方法去调用 methods 中对应方法
- }
- </script>
来源: http://www.bubuko.com/infodetail-3294365.html