according to the official document, if you want to take parameters on url, you can do so
Navigation of programmers "
according to the official document, if you want to take parameters on url, you can do so
Navigation of programmers "
this.$router.push ({
path:'/pathname?id='+1+'&name='=2
})
https://router.vuejs.org/zh/a.
documents all read carefully
simplest:
: to= "/ user/' + id"
{ name: 'user', params: { id: deviceID }}
this elegance
use template strings to look elegant
:to="`/user/${deviceID}`"
personally, I think the name jump of the route is better than path, and it is more readable, and there is no need to write a string of addresses. If you have to path, you can only use strings
:to="{path:`/user/${deviceID }`}"
if you use name, just follow the words "try to learn to smile" upstairs. The example of the official document of reasoning has covered almost all the requirements
. after reading the answers of so many people, I think it's a good way to use template strings to solve the problem. In addition, the meaning of the existence of name
is already very elegant for decoupling. If you find it troublesome to use name, and you have to find a more elegant way to use path, I think you may have some misunderstandings about elegance.
< router-link: to= "{path:'/ user/', params: {id: 123}}" > < / router-link >
if you jump based on the current address, you can add append:
< router-link: to= "{path:'/ user/', params: {id: 123}}" append > < / router-link >
abandoned vue and embraced angular. Of course, it is not just because of routing that angular is a complete "framework". Of course, the most important thing is ts?,. Of course, vue is still in use. After all, the slope of angular is too high
. < hr >angular routing completely solves my problem
{ path: 'hero/:id', component: HeroDetailComponent }
<a [routerLink]="['/hero', hero.id]">
ide/router-sharproute-parameters" rel=" nofollow noreferrer "> https://angular.cn/guide/rout.
< hr >complain about the name field of vue-router. I really can't figure out the meaning of this field. Let me give you an example.
* console
* log
* user
* log
{
path: 'console/log/:id',
name: 'log'
},
{
path: 'user/log/:id',
name: 'log'
}
if this is the requirement, won't the name values conflict? Okay, you'll say it's the same as the path value, using the hump
.{
path: 'console/log/:id',
name: 'consoleLog'
},
{
path: 'user/log/:id',
name: 'userLog'
}
is that right? But it seems to have solved the demand, but in fact, the hidden danger is even greater. Do you want another one?
{
path: '/console',
children: [
{
path: 'device',
children: [
{
path: 'peripheral',
children: [
{
path: 'log'
}
]
}
]
},
{
path: 'setting',
children: [
{
path: 'user',
children: [
{
path: 'action',
children: [
{
path: 'log'
}
]
}
]
}
]
}
]
}
what if I need to name two log for a path like this? Or should I name action and peripheral?
{
path: 'console/device/peripheral/log'
name: 'consoleDevicePeripheralLog'
}
do you have to write two lines like this? In the future, there will be more demand and more sub-routes. It is not enough to write a path. If the demand needs to be changed device
, I will have to change path and name, respectively. I am afraid of both
looking at the ide/essentials/navigation.html-sharp%E7%BC%96%E7%A8%8B%E5%BC%8F%E7%9A%84%E5%AF%BC%E8%88%AA" rel=" nofollow noreferrer "> programmer's navigation in the vue-router document I can't imagine that the combination of path and params is not included in it. Instead, it uses the most primitive string concatenation. Fortunately, es6 has backquotes. Otherwise, it will be even worse.
Previous: The IOS table selectRow method selects cell and does not trigger the didSelectRowAt method
there is such a background system, which is divided into many systems and modules, which involves a lot of operation permissions, and each lander is assigned different permissions, so the operable menus and visible pages are also different. the previo...
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Document< title> < head> <body> <div id="app"> <h1>Hello App!< h1> <...
I looked at the official document and I didn t understand it. How should I write it in this.$router.push ( xx1 xx2 )? ...
Wechat pay in Alipay, complete the payment by opening the system browser. The project is built on vue. Instead of the current page being opened via safari, you are going to the root directory of the route. Not even history with mode. Dear gods, how to so...
I am working on a page customization function. The template is stored in the background database, so you need to pull the template id, from the background and then follow the template id require corresponding to the components in the directory. For exam...
the this.$route.params.id obtained during vue route switching remains the same. you need to click the category and then click the computer before the phone can be changed, as shown in figure . Click the category-- Mobile idid1 --id the code is as ...
<div class="title"> <span>< span> <router-link to=" buy_car">go< router-link> < div> I want to click on this < router-link >, jump to the route buy_car, and pass several parameters to b...
there is navigation on the left and above. wants the navigation not to move when you jump. renders the contents of the child route on the lower right. originally intended to use v-if to bind to the parent route element Click on the link and render t...
in navigational programming in vue-router: router.push({ path: ` user ${userId}` }) -> user 123 can be written as: router.push({ path: user ${userId} }) ? is there any difference between ``and here? if there is no difference, then ...
vue project, use Wechat s third-party website to scan the code to log in, according to the official document first step var obj = new WxLogin({ self_redirect:true, id:"login_container", appid: "", scope: "", ...
when defining routes: const routes = [{ path: , meta: { title: }, component: (resolve) => require([ . views index.vue ], resolve) children: [ { path: a , name: a , title: a , component: ...
Brotherhood question link: https: codeshelper.com q 10. displays the text on the home page by default http: localhost:8080 Fen app.vue <template> <div id="app"> <Header>< Header> <div class="...
in my routes.js : ... children: [ { path: a , name: a , title: a , component: (resolve) => require([ . views a a.vue ], resolve) }, { path: b , name: b , title: b , compo...
1. The animation is divided into two stages -1-enter the animation -2 from the main page and return to the main page 2. Problem description: when entering the details page from the main page, the main page is destroyed instantly, leaving the details p...
as shown in the figure, are there any ideas or ready-made plug-ins? elementUI looked at it and found that it could not support dynamic component switching. ...
use vue router to imitate the app page to slide in and out, and there is a white gap between the two pages when Synchronize goes in and out. what is the reason for this? The official document says that if you do not set mode, it is the default Synchroni...
the project is built by vue-cli. SAP, runs without error with npm run dev. After using npm run build, the generated js is put into erb and reported to cannot redefine $router,. Some answers say that vue router is defined twice, or vue is packaged twice,...
Vue rookie, is trying to do a SPA page, encountered a problem looked at a lot of information can not be solved, come here to ask for the opinions of your predecessors. can vue-router get background data directly? How should it be done? If not, whether...
how to switch the online and offline domain name url and how to configure config? ask for answers ...
uses the following four columns made by vue-router, which is the product details interface, routing to productdescription, under the four columns of product information, purchase records, customer reviews, buyer questions and answers for four differen...