How to import functions from different js file in a Vue+webpack+vue-loader project

前端 未结 4 1131
轮回少年
轮回少年 2021-02-01 01:39

(See end for why this is not a dupe of How do I include a JavaScript file in another JavaScript file?)

Javascipt + Vue + webpack + vue-loader noob... stumbling on the si

4条回答
  •  不思量自难忘°
    2021-02-01 02:02

    Say I want to import data into a component from src/mylib.js:

    var test = {
      foo () { console.log('foo') },
      bar () { console.log('bar') },
      baz () { console.log('baz') }
    }
    
    export default test
    

    In my .Vue file I simply imported test from src/mylib.js:

    
    

提交回复
热议问题