
Security News
Opengrep Adds Apex Support and New Rule Controls in Latest Updates
The latest Opengrep releases add Apex scanning, precision rule tuning, and performance gains for open source static code analysis.
vue-mobile-virtual-keyboard
Advanced tools
受夠了需求老是要求【只能輸入純數字】【只能輸入身份證】的要求了
受夠了動不動就正則替換的人了
受夠了第三方輸入法的單詞聯想了
我要有一個自定義的鍵盤!
支持插件形式調用
// 在入口文件全局引入
import Vue from 'vue';
import KeyboardComponent from './plugin/keyboard';
Vue.component(KeyboardComponent);
<script>
import keyboard from './../components/keyboard.vue';
export default {
components: {
keyboard
}
}
</script>
考慮到自由性,暫時不準備將組件和 input
強綁定在一起,缺點就是值要自己處理了
下例為精簡demo,如果一個頁面中存在兩個不同佈局的鍵盤,可詳細參看完整demo:src/pages/index.vue
// 顯示
this.$keyboard.show({
onKeyClick (key) {},
onDelete () {}
});
// 隱藏
this.$keyboard.hide();
// 獲取顯示狀態
this.$keyboard.isVisible();
// 更新配置
this.$keyboard.update({
propKeyList: lowerKeyList
});
<div class="demo-input">
<div class="demo-input-hd">手機</div>
<div class="demo-input-bd" @click="toShowKeyboard('phoneNumber')">
<!-- 定義ref來取得target的dom -->
<input ref="phoneNumber" v-model="phoneNumber" disabled="disabled" readonly="readonly" max="11">
</div>
</div>
<keyboard :show.sync="showKeyboard" @on-key-click="onKeyClick" @on-delete="onDelete"></keyboard>
<script>
export default {
methods: {
toShowKeyboard (target) {
this.target = target; // 傳遞編輯target
this.showKeyboard = true;
},
onKeyClick (key) {
if (this.$refs[this.target] && this[this.target].length + 1 === parseInt(this.$refs[this.target].max)) {
return;
}
this[this.target] += key;
},
onDelete () { // 刪除
this[this.target] = this[this.target].slice(0, this[this.target].length - 1);
}
}
}
</script>
插件使用和template使用中,可使用的屬性和事件是一樣的,區別為:插件使用時屬性事件命名為 駝峰
show [Boolean]:顯示
propKey-list [Array]:鍵盤keymap,默認為九宮數字鍵盤
數組中按鈕接收三種格式:String,Number,Object
[String,Number]:每一行的按鍵大小為 (100 / 當行按鍵數)%
[Object]:必須定義 code
和 span
屬性,alias
選填
{
code: 'space', // 按鍵顯示名
span: '5/8', // 佔用寬度,分子/分母
alias: ' ' // 別名,即實際輸出。若不定義,則取code
}
delete-key [String]:指定刪除鍵
confirm-key [String]:指定確認鍵
click
事件置換成 touchend
事件;QQ:3088680950
如果發現八阿哥了或者有功能上的建議,推薦通過 issue
發起討論。
我已經幾年沒上QQ了(
MIT license. 有好的想法歡迎提供。
FAQs
A keyboard component in vue.
The npm package vue-mobile-virtual-keyboard receives a total of 6 weekly downloads. As such, vue-mobile-virtual-keyboard popularity was classified as not popular.
We found that vue-mobile-virtual-keyboard demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
The latest Opengrep releases add Apex scanning, precision rule tuning, and performance gains for open source static code analysis.
Security News
npm now supports Trusted Publishing with OIDC, enabling secure package publishing directly from CI/CD workflows without relying on long-lived tokens.
Research
/Security News
A RubyGems malware campaign used 60 malicious packages posing as automation tools to steal credentials from social media and marketing tool users.