a標(biāo)簽使用href="javascript:void(0); "在火狐瀏覽器跟chrome 不兼容
使用如下方式的鏈接鳖粟。在Chrome中點(diǎn)擊后行為符合預(yù)期,但在IE下會(huì)新開標(biāo)簽卡(根據(jù)參考資料,F(xiàn)irefox中有相同問(wèn)題)穴店。
<a href="javascript:void(0);" target="_blank">test</a>
后經(jīng)查找資料伙判,發(fā)現(xiàn)需如下解決。
通過(guò)onclick阻止瀏覽器默認(rèn)事件:<a οnclick="return false;" href="javascript:void(0);" target="_blank">test</a>
或直接:<a target="_blank">test</a>
原因在于三款瀏覽器蚕礼,對(duì)三個(gè)屬性的處理順序不同。
Chrome順序:onclick -> href -> target
IE和Firefox順序:onclick -> target -> href
- <a οnclick="fn()">Does not appear as a link, because there's no href</a>
- <a href="javascript:void(0)" οnclick="fn()">fn is called</a>
- <a href="javascript:undefined" οnclick="fn()">fn is called</a>
- <a href="javascript:" οnclick="fn()">fn is called too!</a>
不用a標(biāo)簽了梢什,改用elementUI的button
<el-button type="text" @click="handleClick(scope.row)" >{{scope.row.name}}</el-button>