Closed mengdu closed 1 year ago
https://codesandbox.io/s/mutable-sky-22l4gj
router.push('/hello?return_url=' + encodeURIComponent('https://www.my.com'))
and
router.push({ path: '/hello', query: { return_url: encodeURIComponent('https://www.my.com') } })
/hello page
/hello
<script setup lang="ts"> import { useRouter, useRoute } from 'vue-router' const route = useRoute() console.log('hello', route.query) // hello {return_url: 'https://www.my.com'} // hello {return_url: 'https%3A%2F%2Fwww.my.com'} </script> <template> <div>Hello</div> </template>
I want got route.query = {return_url: 'https://www.my.com'} but inconsistent results
{return_url: 'https://www.my.com'}
Multiple encodeURIComponent
No response
Do not encode when passing a query object. The router does it for you 🙂
Reproduction
https://codesandbox.io/s/mutable-sky-22l4gj
Steps to reproduce the bug
and
/hello
pageExpected behavior
I want got route.query =
{return_url: 'https://www.my.com'}
but inconsistent resultsActual behavior
Multiple encodeURIComponent
Additional information
No response