简体   繁体   中英

Is it possible to Import file in JS file using URL

I have little older version of vue.js ("vue": "^2.2.2") defined in package.json

Which I access in my JS like this:

import Vue from 'vue'

But, I like to quickly test if things are working fine with newer version of vue.js.

import Vue from '//unpkg.com/vue@2.4.1'

If not possible, any better ways?

the node-multidep project aims to solving this problem.

Create a json file test/multidep.json

{
  "path": "test/multidep_modules",
  "versions": {
    "vue": ["2.2.2", "2.4.1"]
  }
}

then:

npm install --save-dev multidep
./node_modules/.bin/multidep test/multidep.json

and finally in your js file, uncomment the line of the vue version you want to use:

var multidepRequire = require('multidep')('test/multidep.json')

var Vue = multidepRequire('vue', '2.2.2')
// var Vue = multidepRequire('vue', '2.4.1')

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM