html搜尋 中英文狀態 如何區分

來源:互聯網
上載者:User

標籤:down   event   change   pen   app   position   分享   bfd   組合   

本文主要解決的問題; 中文IME下  如何做到不會用拼音搜尋

可參考: https://zhuanlan.zhihu.com/p/25709544

 

<!DOCTYPE html><html lang="en"><head>    <meta charset="UTF-8">    <title>input輸入框for中文IME</title>    <script src="vue-2.js "></script>    <style>        .div{            margin-bottom: 10px;        }    </style></head><body><div id="app">    <label for="">監聽onchange事件</label>    <input type="text" v-model="changetext" v-on:change="change"  placeholder="請試試中文IME和英文IME">    <div>        onchange輸入值:{{changevalue}}    </div>    <label for="">keydown事件</label>    <input type="text" v-model="keydowntext" @keydown="keydown" placeholder="請試試中文IME和英文IME">    <div>        keydown輸入值:{{keydownvalue}}    </div>    <label for="">監聽input事件,@input="input"(vue1 不可用,vue2 可用)</label>    <input type="text" v-model="inputtext"  @input="input" placeholder="請試試中文IME和英文IME">    <div>        input輸入值:{{inputvalue}}    </div></div><script src="//cdn.bootcss.com/vue/2.1.10/vue.js"></script><script >    new Vue({        el: ‘#app‘,        data: {            inputvalue: ‘‘,            inputtext: ‘‘,            changevalue: ‘‘,            changetext: ‘‘,            keydownvalue: ‘‘,            keydowntext: ‘‘,            compositiontext: ‘‘,            compositionvalue: ‘‘        },        methods: {            input: function (val) {                //console.log(this.inputtext+ "  " + this.inputtext)                if (this.inputtext != this.inputvalue) {                    console.log("input:" + this.inputtext)                    this.inputvalue = this.inputtext                }            },            compositioninput: function (val) {                console.log("compositioninput:" + this.compositiontext)                this.compositionvalue = this.compositiontext            },            change: function (val) {                console.log("change:" + this.changetext)                this.changevalue = this.changetext            },            keydown: function (val) {                console.log("keydown:" + this.keydowntext)                this.keydownvalue = this.keydowntext            },            compositionend: function(val) {                console.log("compositionend:" + this.compositiontext)                this.compositionvalue = this.compositiontext            }        }    })</script></body></html>
View Code
<!DOCTYPE html><html lang="en"><head>    <meta charset="UTF-8">    <title>input輸入框for中文IME</title>    <script src="vue-1.js "></script>    <style>        .div{            margin-bottom: 10px;        }    </style></head><body><div id="app">    <label for="">監聽onchange事件</label>    <input type="text" v-model="changetext" v-on:change="change"  placeholder="請試試中文IME和英文IME">    <div>        onchange輸入值:{{changevalue}}    </div>    <label for="">keydown事件</label>    <input type="text" v-model="keydowntext" @keydown="keydown" placeholder="請試試中文IME和英文IME">    <div>        keydown輸入值:{{keydownvalue}}    </div>    <label for="">監聽input事件,@input="input"(仍舊無法監聽組合事件)</label>    <input type="text" v-model="inputtext"  @input="input" placeholder="請試試中文IME和英文IME">    <div>        input輸入值:{{inputvalue}}    </div>    <label for="">input+composition 監聽compositionend事件,@compositionend="compositionend"</label>    <input type="text" v-model="compositiontext" @input="compositioninput" @compositionend="compositionend" placeholder="請試試中文IME和英文IME">    <div>        input輸入值:{{compositionvalue}}    </div></div><script >    new Vue({        el: ‘#app‘,        data: {            inputvalue: ‘‘,            inputtext: ‘‘,            changevalue: ‘‘,            changetext: ‘‘,            keydownvalue: ‘‘,            keydowntext: ‘‘,            compositiontext: ‘‘,            compositionvalue: ‘‘        },        methods: {            input: function (val) {                console.log("input:" + this.inputtext)                this.inputvalue = this.inputtext            },            change: function (val) {                console.log("change:" + this.changetext)                this.changevalue = this.changetext            },            keydown: function (val) {                console.log("keydown:" + this.keydowntext)                this.keydownvalue = this.keydowntext            },            compositioninput: function (val) {                if(this.compositionvalue != this.compositiontext) {                    console.log("do query 2:" + this.compositiontext)                    this.compositionvalue = this.compositiontext                }            },            compositionend: function(val) {                console.log("do query:" + this.compositiontext)                this.compositionvalue = this.compositiontext            }        }    })</script></body></html>
View Code

 

html搜尋 中英文狀態 如何區分

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.