UNPKG

altenterorenter

Version:
43 lines (38 loc) 1.23 kB
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Document</title> <script src="https://cdn.jsdelivr.net/npm/vue@2.6"></script> <script src="https://cdn.jsdelivr.net/npm/@vue/composition-api@1.7.0"></script> <script src="https://unpkg.com/@vueuse/shared"></script> <script src="https://unpkg.com/@vueuse/core"></script> <script src="../src/index.js"></script> <script> const { useEventListener } = VueUse; const { ref, watch } = VueCompositionAPI; Vue.use(VueCompositionAPI) useEventListener(window, 'load', (e) => { const app = new Vue({ el: "#app", directives: { altEnterOrEnter }, setup() { const text = ref(""); function handleEnter(e) { console.log("Enter", e); } watch(text, (val) => console.log(val)) return { text, handleEnter }; } }); }) </script> </head> <body> <div id="app"> <textarea v-alt-enter-or-enter="handleEnter" v-model="text"></textarea> </div> </body> </html>