refer to head in index.html, and then add a sentence
Vue.prototype.xxx = xxx
in the main.js under the src directory, in which xxx is the js exposed object of your chain
usage:
this.xxx.alert ('h')
Yes, just write it in index.html
save it locally and then reference it, and the require parsed by import is just looking for resources locally.
you can try
the first step
npm install jquery-- save
step 2
add
to build/webpack.base.conf.js
var webpack = require ("webpack")
step 3
also in build/webpack.base.conf.js
add
plugins: at the end of the module.exports [
new webpack.optimize.CommonsChunkPlugin('common.js'),
new webpack.ProvidePlugin({
jQuery: "jquery",
$: "jquery",
"windows.jQuery": "jquery"
})
]
step 4
introduce import $from 'jquery' in main.js
step 5
npm run dev restart the server
I mean that the path is already supported, and it is also an outer chain. As for the local . / my-module.js
, you are actually adding http://url/
to the browser.
index.html
<script type="module">
import {foo} from "http://url/my-module.js";
console.log(foo)
</script>
my-module.js
export const foo = Math.PI + Math.SQRT2;
can't it be directly introduced into html? I remember that the js of the geographical location analysis of QQ that I cited earlier was so directly cited.