vscode中外部引入js文件以及里面相应的方法

随便写一个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啦
 
 
放上参考网站:
posted @ 2019-09-12 09:41  阿蒙不萌  阅读(8343)  评论(0编辑  收藏  举报