mirror of
https://github.com/tenrok/maska.git
synced 2026-06-08 17:22:27 +03:00
Optimize directive work
This commit is contained in:
@@ -0,0 +1,13 @@
|
||||
<script setup lang="ts">
|
||||
import { ref } from 'vue'
|
||||
|
||||
import { vMaska } from '../../src'
|
||||
import CustomInput from './CustomInput.vue'
|
||||
|
||||
const value = ref('')
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<CustomInput v-maska data-maska="#-#" data-maska-eager v-model="value" />
|
||||
<div>{{ value }}</div>
|
||||
</template>
|
||||
@@ -0,0 +1,11 @@
|
||||
<script setup>
|
||||
defineProps(['modelValue'])
|
||||
defineEmits(['update:modelValue'])
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<input
|
||||
:value="modelValue"
|
||||
@input="$emit('update:modelValue', $event.target.value)"
|
||||
/>
|
||||
</template>
|
||||
@@ -0,0 +1,11 @@
|
||||
<script setup lang="ts">
|
||||
import { ref } from 'vue'
|
||||
import { vMaska } from '../../src'
|
||||
|
||||
const value = ref('123')
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<input v-maska data-maska="#-#" data-maska-eager v-model="value" />
|
||||
<div>{{ value }}</div>
|
||||
</template>
|
||||
@@ -0,0 +1,44 @@
|
||||
<script setup lang="ts">
|
||||
import { reactive, ref } from 'vue'
|
||||
import { vMaska } from '../../src'
|
||||
|
||||
const emit = defineEmits(['mask1', 'mask2'])
|
||||
|
||||
const isEager = ref(false)
|
||||
|
||||
const value1 = ref('123')
|
||||
const value2 = ref('321')
|
||||
|
||||
const options = reactive({
|
||||
eager: isEager,
|
||||
onMaska: () => null
|
||||
})
|
||||
|
||||
const onMaska1 = () => {
|
||||
emit('mask1')
|
||||
}
|
||||
|
||||
const onMaska2 = () => {
|
||||
emit('mask2')
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<input id="checkbox" type="checkbox" v-model="isEager" />
|
||||
<input
|
||||
id="input1"
|
||||
v-maska:[options]
|
||||
data-maska="#-#"
|
||||
v-model="value1"
|
||||
@maska="onMaska1"
|
||||
/>
|
||||
<input
|
||||
id="input2"
|
||||
v-maska
|
||||
data-maska="#-#"
|
||||
v-model="value2"
|
||||
@maska="onMaska2"
|
||||
/>
|
||||
<div id="value1">{{ value1 }}</div>
|
||||
<div id="value2">{{ value2 }}</div>
|
||||
</template>
|
||||
Reference in New Issue
Block a user