求助,关于vue2中使用Vue.prototype,如何在vue2的组合式api中获取到? #9887
Answered
by
Alfred-Skyblue
Liubei1993
asked this question in
Help/Questions
-
我有一个项目是用vue2开发的,创建时用Vue.prototype挂载了一个参数,比如$name。然后我引入了一个插件,插件使用vue2并通过@vue/composition-api的组合式api来开发,请问我如何在插件中使用这个$name?我用getCurrentInstance获取不到。 |
Beta Was this translation helpful? Give feedback.
Answered by
Alfred-Skyblue
Dec 21, 2023
Replies: 1 comment 1 reply
-
Try using the following methods:
Vue.prototype.$name = 'foo'
<template></template>
<script setup>
const vm = getCurrentInstance()
console.log(vm?.proxy.$root.$name) // foo
<script> |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
Liubei1993
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Try using the following methods: