随便写一个js文件,定义一个方法名,并且在组件中进行引用就算成功

###~js

function shuchu(){
    console.log(1)
}

export { shuchu };
 
###~.vue
<template>
  <div class="hello">
    
    <button @click="gettwo()">点击</button>
    
  </div>
</template>

<script>

import {shuchu} from '../assets/get'

export default {
  data () {
    return {
    }
  },
  methods: {
    gettwo(){
      shuchu();
    }
  },
}
</script>

现在点击就会控制台出现一个1啦
 
 
放上参考网站:

相关文章:

  • 2022-02-08
  • 2021-11-17
  • 2022-12-23
  • 2022-12-23
  • 2022-02-08
  • 2021-10-30
  • 2021-11-21
猜你喜欢
  • 2022-02-09
  • 2021-09-29
  • 2022-12-23
  • 2021-11-21
  • 2021-03-30
  • 2021-12-03
  • 2021-11-21
相关资源
相似解决方案