Vue3像Vue2一样在prototype(原型)上挂载数据

Vue2的写法

import App from './App'
import Vue from 'vue'
import './uni.promisify.adaptor'
Vue.config.productionTip = false
App.mpType = 'app'
import config from "./static/js/config/config.js"
Vue.prototype.$config=config;
const app = new Vue({
  ...App
})
app.$mount()

Vue3的写法

import App from './App'
import { createSSRApp} from 'vue'
import config from './static/js/config/config.js'
export function createApp() {
  const app = createSSRApp(App)
  app.config.globalProperties.$config = config;
  return {
    app
  }
}

使用

console.log(this.$config.baseApi)

你可能感兴趣的:(Vue,uni-app,原型模式,vue.js,javascript)