今天在使用element的tabs组件时,发现这个tab组件自带了按键盘左右方向,切换tab的功能,可以通过使用@keydown.native.capture.stop去除该事件
- <el-tabs v-model="editableTabsValue"
- type="card"
- :addable="true"
- size="small"
- tab-position="top"
- style="height:100%"
- @keydown.native.capture.stop
- ref="tabs">
- el-tabs>
最终的解决办法就是不使用el-input。而是使用原生的input。这样光标就不会总在最后一位了。
- <input
- class="tabInput"
- autocomplete="off"
- type="text"
- @blur="closeRenameTab('msg')"
- @change="closeRenameTab('no')"
- @input.stop
- v-model="one.title" >
- input>
- .tabInput{
- position: relative;
- font-size: 12px;
- display: inline-block;
- -webkit-appearance: none;
- background-color: #fff;
- background-image: none;
- border-radius: 4px;
- border: 1px solid #dcdfe6;
- box-sizing: border-box;
- color: #606266;
- height: 25px;
- line-height: 25px;
- outline: none;
- padding: 0 7px;
- transition: border-color .2s cubic-bezier(.645,.045,.355,1);
- width: 100%;
- }