Can't jump be written directly in the html code in Vue? Will report an error Cannot read property'$router' of null

<li class="col25" @click="this.$router.push({name:"RentList"})"><img width="32px" height="32px" src="../assets/images/home1.png"/><span style="display:block;"></span></li>

do I have to write the js code in method?

Apr.26,2022

this points to
directly @ click= "$router.push ({....})"


1. When rendering the template, there is no $router object. vue provides < router-link to= "/ foo" > Go to Foo < / router-link > for template routing.


just remove the this

Menu