Skip to content

求助,关于vue2中使用Vue.prototype,如何在vue2的组合式api中获取到? #9887

Discussion options

You must be logged in to vote

Try using the following methods:

  • main.ts
Vue.prototype.$name = 'foo'
  • App.vue
<template></template>

<script setup>
const vm = getCurrentInstance()

console.log(vm?.proxy.$root.$name) // foo
<script>

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@Liubei1993
Comment options

Answer selected by Liubei1993
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants