8528b9d6995bc3d0b0d8082d89b9f13eae6e6752c2a527a6cb4732c4ca73be090af5e0157c946c11882fb0fa88730af8597abadb81e740b0fb4f792e76422c 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. /* @flow */
  2. import Vue from 'core/index'
  3. import config from 'core/config'
  4. import { extend, noop } from 'shared/util'
  5. import { mountComponent } from 'core/instance/lifecycle'
  6. import { devtools, inBrowser } from 'core/util/index'
  7. import {
  8. query,
  9. mustUseProp,
  10. isReservedTag,
  11. isReservedAttr,
  12. getTagNamespace,
  13. isUnknownElement
  14. } from 'web/util/index'
  15. import { patch } from './patch'
  16. import platformDirectives from './directives/index'
  17. import platformComponents from './components/index'
  18. // install platform specific utils
  19. Vue.config.mustUseProp = mustUseProp
  20. Vue.config.isReservedTag = isReservedTag
  21. Vue.config.isReservedAttr = isReservedAttr
  22. Vue.config.getTagNamespace = getTagNamespace
  23. Vue.config.isUnknownElement = isUnknownElement
  24. // install platform runtime directives & components
  25. extend(Vue.options.directives, platformDirectives)
  26. extend(Vue.options.components, platformComponents)
  27. // install platform patch function
  28. Vue.prototype.__patch__ = inBrowser ? patch : noop
  29. // public mount method
  30. Vue.prototype.$mount = function (
  31. el?: string | Element,
  32. hydrating?: boolean
  33. ): Component {
  34. el = el && inBrowser ? query(el) : undefined
  35. return mountComponent(this, el, hydrating)
  36. }
  37. // devtools global hook
  38. /* istanbul ignore next */
  39. if (inBrowser) {
  40. setTimeout(() => {
  41. if (config.devtools) {
  42. if (devtools) {
  43. devtools.emit('init', Vue)
  44. } else if (
  45. process.env.NODE_ENV !== 'production' &&
  46. process.env.NODE_ENV !== 'test'
  47. ) {
  48. console[console.info ? 'info' : 'log'](
  49. 'Download the Vue Devtools extension for a better development experience:\n' +
  50. 'https://github.com/vuejs/vue-devtools'
  51. )
  52. }
  53. }
  54. if (process.env.NODE_ENV !== 'production' &&
  55. process.env.NODE_ENV !== 'test' &&
  56. config.productionTip !== false &&
  57. typeof console !== 'undefined'
  58. ) {
  59. console[console.info ? 'info' : 'log'](
  60. `You are running Vue in development mode.\n` +
  61. `Make sure to turn on production mode when deploying for production.\n` +
  62. `See more tips at https://vuejs.org/guide/deployment.html`
  63. )
  64. }
  65. }, 0)
  66. }
  67. export default Vue