JavaScript/vue.js/getCurrentInstance:修订间差异
来自康健生活
| (未显示同一用户的1个中间版本) | |||
| 第36行: | 第36行: | ||
</syntaxhighlight> | </syntaxhighlight> | ||
以及 | |||
{{hc|head=./src/main.js|output=<syntaxhighlight lang="javascript"> | |||
import { createApp } from 'vue' | |||
import { store } from './store' | |||
const app = createApp(App) | |||
app.provide('appMounted', app ) | |||
</syntaxhighlight>}} | |||
借助 provide 注册顶层变量的另外一个思路是包装成一个插件 | |||
<syntaxhighlight lang="javascript"> | <syntaxhighlight lang="javascript"> | ||
| 第113行: | 第123行: | ||
store.commit('appMounted', app ) | store.commit('appMounted', app ) | ||
// useage: store.state.appMounted | // useage: store.state.appMounted | ||
</syntaxhighlight>}} | </syntaxhighlight>}} | ||