Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

关于公共js的问题 #19

Open
zhongziqi opened this issue Jan 13, 2018 · 1 comment
Open

关于公共js的问题 #19

zhongziqi opened this issue Jan 13, 2018 · 1 comment

Comments

@zhongziqi
Copy link

现在就比如,我想将一些公共的js方法注入到每一个页面,从楼主的代码来看的话,需要在每一个页面中引入,那能不能只引一次js公共方法就能实现所有页面共享呢???

@Bimbaloo
Copy link

你可以试一下webpack自带的ProvidePlugin插件。
在每个页面自动引入vue、vue-router、vuex

module.exports = {
  entry: utils.entries(),
  output: {...},
  plugins: [
    new webpack.ProvidePlugin({
      Vue: 'vue',
      Router: 'vue-router',
      Vuex: 'vuex'
    })
  ],
  resolve: {...}
  ......
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants