I\'m using Vue.js with Nuxt in SSR, I would like when I highlight some text to get this text and perform an action on it.
I found a way to do that with
I'm unclear on whether you want to react to a selection inside the input or elsewhere in the document. Assuming inside the input:
mouseup event.$event.getSelection() doesn't work on input values, so use selectionStart and selectionEnd to get the selection.new Vue({
el: '#app',
methods: {
logSelectionWithinInput(e) {
var selection = e.target.value.substring(
e.target.selectionStart,
e.target.selectionEnd
);
console.log(selection);
}
}
});