将methods里面定义的方法, 需要赋值给window,外部js就可以调用了

export default {
   data() {
       return {
           title: '测试',
       }
   },
    mounted() {
        // 将vue中的方法赋值给window
       window.selectUser = this.selectUser;
    },
    methods: {
        selectUser() {
           console.log('selectUser');
        },
    }
}

js或网页就可以调用了

<input type="button" class="btn-select" value="选择" onclick="selectUser()"/>

 

相关文章:

  • 2021-11-21
  • 2021-06-17
  • 2021-06-08
  • 2022-12-23
  • 2022-12-23
  • 2021-07-28
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2023-02-27
  • 2021-11-21
  • 2021-12-03
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案