ambit-tsai / vue2-helpers Goto Github PK
View Code? Open in Web Editor NEW🔧 A util package to use Vue 2 with Composition API easily
License: Apache License 2.0
🔧 A util package to use Vue 2 with Composition API easily
License: Apache License 2.0
This is on Vue 2.7.
When I add a guard with onBeforeRouteLeave
(inside a composable), the specified guard function is registered and called as expected. If I however manage to leave the page (because the guard allowed it) and then enter the same route/component again, a new guard is registered but the previous one is also still active and called. I validated this by printing out calls to the guard, including an auto-generated id of a computed ref that is created within the component.
This is problematic in my case because the guard relies on a computed "canLeave" flag to prompt for user confirmation and that is never updated after the page was left, meaning if the page was left, reentered and then the user wants to leave again, they will always be prompted even if they didn't make any changes on the page they are currently on.
npm i -g pnpm
pnpm install
pnpm run dev
route.query: {}
at first.toQuery
button. Should see route.query: { "a": "1" }
.useQuery2
button. Should see route.query: { "a": "2" }
, but actually see route.query: { "a": "1" }
.useQuery1
button. Should see route.query: { "a": "1" }
.Why I see route.query: { "a": "1" }
in Step 2? I did something wrong? Any suggestions? :D
route.query: {}
。toQuery
按钮。应该会看到 route.query: { "a": "1" }
。useQuery2
按钮。应该会看到 route.query: { "a": "2" }
,但实际上看到 route.query: { "a": "1" }
。useQuery1
按钮。应该会看到 route.query: { "a": "1" }
。为什么我在步骤 2 会看到 route.query: { "a": "1" }
?我写错哪里了吗?有什么建议吗?:D
Where is the source code of v1.1.7?
请问能提供1.1.7版本的源码吗,仓库目前似乎还是1.1.6的
Since Vue 2.7.0, the value returned by getCurrentInstance()
function has always been null.
Please change import getCurrentInstance()
function from vue
.
import { getCurrentInstance } from '@vue/composition-api';
to
import { getCurrentInstance } from 'vue';
i use vue 2.7.13, in <script setup>, but useRouter() log undefined
<script setup>
import { useRouter } from 'vue2-helpers/vue-router'
const router = useRouter()
console.log('router', router) // router is undefined
</scirpt>
I tested out vue-helpers with Vue 2.7 Beta 5 and I found the router is undefined. I know it is just a beta release but they were asking devs to test out their apps with 2.7 and report bugs.
const router = useRouter()
For now I am using the following workaround with Vue 2.7 and <script setup>
<script>
let router;
</script>
<script setup>
import { useRouter } from 'vue2-helpers/vue-router';
router = useRouter();
</script>
I upgraded to the latest Vue 2.7.11 and I get the error:
Cannot read properties of undefined (reading '_router')
My current work around is to call useRouter on mounted in script setup to avoid the undefined error.
onMounted(() => {
router = useRouter();
})
可以把 vue 从dependencies改到peerDependencies么。毕竟用这个插件的话,都会用本地的vue,因为插件本身dependencies带有vue,导致我这边使用的时候无法获取到正确的结果
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.