getCurrentInstance 保持 vue2 和 vue3 接口一致

This issue has been created since 2022-07-28.

What problem does this feature solve?

目前在做一个组件库,同时支持 vue2 和 vue3 的,想最新的 2.7.x 可以保持 getCurrentInstance 在 vue2 和 vue3 接口一致,目前 vue2 返回只有一个 proxy,用起来不是很方便

What does the proposed API look like?

在 vue2 场景下, getCurrentInstance 和 vue3 一致

YFengFly wrote this answer on 2022-08-06

即便 API 保持一致,也会遇到一些数据劫持的不同,Vue 2.7 依然需要 set 来绑定数据:
https://blog.vuejs.org/posts/vue-2-7-naruto.html
尤其若遇到 Vue 2.6 以及更低版本,配合了 @vue/componsition-api ,那么还会有更多的数据操作的不同,作为库作者都是要注意这些细节的。
既然如此,那么预先用 app.version / Vue.version 判断一下版本还是更合适一些

yyx990803 wrote this answer on 2022-08-09

getCurrentInstance 返回的是 internal instance,除了 proxy 外(等同于 public instance)其它属性都视为私有属性,想要保持一致应该避免使用除 proxy 外的其它属性。

More Details About Repo
Owner Name vuejs
Repo Name vue
Full Name vuejs/vue
Language TypeScript
Created Date 2013-07-29
Updated Date 2022-09-27
Star Count 199644
Watcher Count 6098
Fork Count 32848
Issue Count 587

YOU MAY BE INTERESTED

Issue Title Created Date Comment Count Updated Date
Video caching should be use indexeddb 1 2021-12-16 2022-08-23
I can't upload files from novawallet - to create a collection 0 2022-07-30 2022-09-22
Issue uploading the dataset 1 2022-04-13 2022-09-26
Problem of "_pickle.UnpicklingError: pickle data was truncated" 0 2022-02-18 2022-08-03
How to render correctly? 3 2022-03-22 2022-07-23
Render 4-channel image? 2 2022-04-22 2022-07-09
Unable to reproduce paper results 3 2022-04-18 2022-05-09
Proteksi Halaman dengan express-basic-auth 0 2022-01-15 2022-09-10
DesktopDatePicker - changing views causes jarring popover position changes 1 2022-07-14 2022-08-22
[data grid] With custom position filter panel is shown outside table view 1 2022-07-14 2022-09-25
how do i capture logging events of my reader 1 2020-03-04 2022-09-12
[QUESTION]: Is it actually ripping from tidal? ("Fakin' The Funk" showing actual bitrate only 128kbps) 3 2022-06-15 2022-09-21
error creating ecs-fargate-example service: InvalidParameterException: The target group with targetGroupArn arn:aws:elasticloadbalancing:us-east-1:xxxxxxxx:targetgroup/tg-fargate-example/97c07ffe67daf38f does not have an associated load balancer. 2 2021-09-02 2022-08-08
Request to provide support to activate the previous window of the same application 0 2022-01-16 2022-07-14
PET examples need to be updated 2 2021-01-13 2022-09-13
ur3_moveit_config: setup assistant process dies 5 2020-07-13 2022-09-05
Installation instructions: please update the readme front page 5 2021-07-20 2022-09-16
Fix current working directory hack 0 2021-07-03 2022-09-16
Automated functional tests 2 2021-06-28 2022-09-16
support iterable/list values as @Body 2 2022-05-20 2022-09-23
Marlec iBoost not working. Device 188 7 2022-02-17 2022-09-24
github action examples 0 2022-05-17 2022-09-07
Library contains references to both AndroidX and old support library. This seems like the library is partially migrated. Jetifier will try to rewrite the library anyway. 5 2021-04-09 2022-09-18
Make sure stuff works before ECCV 0 2020-07-16 2022-09-08
Reason to freeze_batchnorm 1 2020-06-15 2022-09-16
Default to BaseAPIParser if a matching API parser is not found 0 2020-07-27 2022-09-24
vivo x27pro android10 进入商品扫码页面黑屏,息屏后或home建退出再进入项目,相机好用 4 2022-03-18 2022-09-19
yolo-nano训练的模型大小和官方预训练模型大小不一致,介于nano和tiny之间,parameters和gflops也差太多 3 2022-05-10 2022-09-21
A Post should not be clickable on its page. 2 2021-10-07 2022-09-16
Facing deployment issue at us-east-1 region 1 2021-01-28 2022-08-23
求一个新版本手机上运行的方法 0 2021-12-27 2022-01-09
CSS file paths in Vite 3 manifest broken on Windows 3 2022-07-22 2022-09-16
Vulneribility - High -Uncontrolled Resource Consumption in trim-newlines 2 2022-07-01 2022-09-14
Get-AipServiceUserLog -fordate out by one bug 2 2021-09-17 2022-09-23
Write-Progress should be updated considering $PSStyle.Progress.View defaults to Minimal 0 2022-06-28 2022-09-23
Add `skeleton-rows` prop to `b-table` component 2 2021-06-26 2022-09-26
TCK failures : 2 SeBootstrapIT tests fail in Linux & mac due to permission issue 32 2022-01-21 2022-09-10
[minio] minio distributed mode install error 2 2022-02-24 2022-07-23
Feature request: Font renderer optimization 0 2021-12-25 2022-09-16
`InitCommand.preprocess` is non-functional 0 2021-12-30 2022-06-30
Add version metadata to windows `fluent-bit.exe` executable 4 2021-12-23 2022-09-16
Many video 1 2017-12-05 2021-12-28
Taking minutes for OrchestrationTrigger to start running 19 2022-06-06 2022-09-19
consider accepting transport instance in CloudLoggingHandler 1 2022-02-10 2022-09-25
"Connection Timed Out" on V2 Web Portal/Cloudflare redirect blocked 3 2022-06-19 2022-09-12
GPU program failed to execute at ___ 2 2019-05-19 2021-12-27
Leaking ZimMangerViewModel 1 2021-03-15 2022-08-29
Missing documentation for `Data.Generic.Vector.New` 0 2021-08-11 2022-09-21
Swiper在条件渲染(根据数组长度) + 动态获取数据时, autoplay会失效 0 2022-07-25 2022-09-07
"dotnet watch" Hot Reload doesn't work if passing arguments 3 2022-01-17 2022-08-23