首页 > 编程知识 正文

vue中a标签的href属性的写法,vue使用window.location.href

时间:2023-05-04 14:27:36 阅读:264176 作者:3354

不要使用vue.min.js,要用vue.js,可以显示报错信息。

代码段

<ol class="breadcrumb"> <li><a rel="external nofollow" href="shopkeeper_category_list">所有分类</a></li> <li><a :rel="external nofollow" href="'shopkeeper_product_list?cid='+category.id">{{category.name}}</a></li> <li class="active">产品管理</li> </ol>

如跳转url为shopkeeper_category_list,该链接不需要动态获取data中的数据作为参数,则无需使用:href,使用href即可。

因为:href具有绑定意义,会即刻寻找名为“shopkeeper_category_list”的变量。

如跳转url为'shopkeeper_product_list?cid='+category.id,需要从变量中的category获取category.id,则需要绑定category.id。

 

<td> <a rel="external nofollow" href="#nowhere" @click="deleteBean(bean.id)">shopkeeper_category_list <span class="glyphicon glyphicon-trash"></span> </a> </td>

另外,使用vue不要写:href=“#nowhere”。vue会自动识别名为nowhere的块,并进行绑定。而非预想的无超链接的作用……

版权声明:该文观点仅代表作者本人。处理文章:请发送邮件至 三1五14八八95#扣扣.com 举报,一经查实,本站将立刻删除。