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

前端 未结 4 1149
轮回少年
轮回少年 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 01:46

    I like the answer of Anacrust, though, by the fact "console.log" is executed twice, I would like to do a small update for src/mylib.js:

    let test = {
      foo () { return 'foo' },
      bar () { return 'bar' },
      baz () { return 'baz' }
    }
    
    export default test
    

    All other code remains the same...

提交回复
热议问题