全局属性怎么在setup中使用 #14171
Answered
by
baiwusanyu-c
holly9715
asked this question in
Help/Questions
全局属性怎么在setup中使用
#14171
Replies: 1 comment 2 replies
-
|
Beta Was this translation helpful? Give feedback.
2 replies
Answer selected by
baiwusanyu-c
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
app.config.globalProperties.msg = 'hello'
export default {
mounted() {
console.log(this.msg) // 'hello'
}
}
怎么在<script setup><script>中使用这个全局变量,感觉组件式没有特别好在script 中获取全局变量的便捷模式,这个全局变量在template的说能够使用的,只能用window.msg在main.js进行注册使用吗?
Beta Was this translation helpful? Give feedback.
All reactions