随便写一个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啦 放上参考网站: export: https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Statements/export?tdsourcetag=s_pcqq_aiomsg import: https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Statements/import转载于:https://www.cnblogs.com/huchong-bk/p/11510244.html
