鍍金池/ 問(wèn)答/網(wǎng)絡(luò)安全  HTML/ 在Mint ui中search如何觸發(fā)確定事件

在Mint ui中search如何觸發(fā)確定事件

在mint-ui中的搜索框,如何使用類似@keyup.enter這樣的事件?

<mt-search v-model="value" @keyup.enter="xxx"></mt-search>

這樣的寫法不行啊? 官網(wǎng)上也沒(méi)找到具體的例子

回答
編輯回答
萌二代

@keyup.enter.native="xxx"

見(jiàn)文檔:https://mint-ui.github.io/doc...

關(guān)于事件綁定 在 Vue 2.0 中,為自定義組件綁定原生事件必須使用 .native 修飾符: <my-component
@click.native="handleClick">Click Me</my-component> 從易用性的角度出發(fā),我們對(duì)
Button 組件進(jìn)行了處理,使它可以監(jiān)聽(tīng) click 事件: <mt-button
@click="handleButtonClick">Click Me</mt-button> 但是對(duì)于其他組件,還是需要添加
.native 修飾符。

2017年10月2日 06:12
編輯回答
安淺陌

。。你可以在谷歌把這部分html扒下來(lái),在里面的input給個(gè)事件,和雙向綁定

2017年4月18日 05:55
編輯回答
默念

可以參考這里:http://www.xiuyuan.info/?cat=47

2018年5月22日 18:29
編輯回答
壞脾滊

同問(wèn),真官網(wǎng)的文檔正的坑

2017年7月7日 07:22
編輯回答
墨沫

獻(xiàn)上我實(shí)際的代碼:
dom:
<mt-search v-model="value" @keyup.enter.native="search"
cancel-text="取消"
placeholder="搜索">
</mt-search>

js:
methods: {

search () {
  if (this.value.length !== 0) {
    this.$router.push({name: 'search', query: {value: this.value}})
  }
}

}

2018年2月22日 21:06