-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
Allow injecting Vue, app, router #80
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is useful, but one change needed: instead of injecting app
, we should call the inject function before app
is created and pass it the raw options. This way the user can inject additional options into the root instance, for example a Vuex store:
import Vuex from 'vuex'
const store = new Vuex.Store({ ... })
export default ({ Vue, options }) => {
Vue.use(Vuex)
options.store = store
}
Also, I'd change the name from |
@yyx990803 哈哈,老大,我想睡觉了。英语不咋好,就不费劲了。 首先,你的建议很棒,我应该是全盘接受了。 其次,通过 enhanceApp.js 其实就可以搞插件了,在其中注册某些组件,比如 demo-box 之类的,就可以在文档里直接用了。 最后,请收下 PR。🤗 |
lib/app/app.js
Outdated
}) | ||
const options = {} | ||
|
||
enhanceApp({ Vue, options }) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We still need router
here so users can register extra router hooks 😂
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
我自己来好了,你早点睡觉吧哈哈。多谢。
How to inject (define) --- updated Sovled by using configureWebpack https://vuepress.vuejs.org/config/#configurewebpack |
.vuepress/inject.js:
readme.md: